Support » Plugin: Code Snippets » Code to remove category hyperlinks

  • The hyperlinks are used with bbPress (which is a forum plugin) categories. If you go to my website, two of those categories are “Introduction” and “Comment on administrator’s writings.” Does anybody know why, when using the version of Code Snippets that I activated today, when I tried activating the code

    <?php do_action( 'bbp_theme_before_forum_title' ); ?>
    		
    		<?php if  (!bbp_is_forum_category( bbp_get_forum_id())){ ?>
    
    		<a class="bbp-forum-title" href="<?php bbp_forum_permalink(); ?>"><?php bbp_forum_title(); ?></a>
    		
    		<?php } else { ?>
    		
    		<div class="bbp-forum-title"> <?php bbp_forum_title();?> </div>
    		<?php }
    		?>
    		
    		<?php do_action( 'bbp_theme_after_forum_title' ); ?>

    at https://bbpress.org/forums/topic/remove-category-hyperlink/

    there was a critical error on my website, which made it so that couldn’t get to the log in screen. Fortunately, I was able to use

    ?snippets-safe-mode=true

    …Again, my site is at dancing4locations.org. I’m using version 5.5.5 of WordPress, and version 2.6.6 of bbPress.

    I would appreciate help.

    The page I need help with: [log in to see the link]

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter jason4locations

    (@jason975)

    While in safe mode, when I try to click on “All snippets”, “Add new”, “Import”, and “Settings” (the only four options that show up when I hover over Snippets) I get a “There has been a critical error on your website. Please check your site admin email inbox for instructions” message. I couldn’t get ?snippets-safe-mode=true to work on those pages. And, I don’t know how else to deactivate or fix the snippet. I also get that message when I click on Dashboard (and a lot of the other things), even though I thought I was already in Dashboard. I wasn’t getting that message before. Though I don’t know if it is there, I’m still looking in my dashboard to try to find the site admin email inbox, because nothing was sent to my other email address. Thank you.

    Thread Starter jason4locations

    (@jason975)

    I’m pretty sure I was having trouble logging out of another website, and not this one, before. In fact, I’m very sure, because I remember trying to figure out how the site looked when no one was logged in. I might be having trouble logging out now because of the snippet.

    Plugin Author Shea Bunge

    (@bungeshea)

    Remember that adding snippets runs them across each page of your website, so snippets that directly produce content like the one above are best added in a shortcode function or action hook.

    If the URL safe mode is not working, you can always try adding define( 'CODE_SNIPPETS_SAFE_MODE', true ); to wp-config.php.

    Otherwise, it sounds like there may be a wider issue outside of Code Snippets. If you’re able to turn on error reporting on your site, then the messages themselves would be quite helpful to solving this issue.

    Thread Starter jason4locations

    (@jason975)

    Thanks.

    Where is wp-config.php?

    Would a shortcode function or action hook be easier? Are there instruction on how to do it for beginners?

    Thread Starter jason4locations

    (@jason975)

    At https://www.wpbeginner.com/beginners-guide/how-to-edit-wp-config-php-file-in-wordpress/ it says that since wp-config.php contains a lot of sensitive information, it is recommended that you don’t mess with this file unless you have absolutely no other choice. If the safest way is to turn on error reporting, how do I do that?

    Thread Starter jason4locations

    (@jason975)

    Safe mode got me into plugins. If I can turn on error reporting using a plugin, would you please recommend a plugin?

    Thread Starter jason4locations

    (@jason975)

    ?snippets-safe-mode=true didn’t work with Debug by SoniNow Team.

    Thread Starter jason4locations

    (@jason975)

    Should I try UpdraftPlus’s restore option?

    Thread Starter jason4locations

    (@jason975)

    I thought http://dancing4locations.org/?snippets-safe-mode=true was working before, but now it isn’t. What do you think changed?

    Thread Starter jason4locations

    (@jason975)

    I got back into my site using my host’s control panel, but I’m still interested in whether a shortcode function or an action hook would be easier.

    Thread Starter jason4locations

    (@jason975)

    I’m interested in what Shea Bunge said about the problem being that snippets get run across each page of my website. The default is to run snippet everywhere, but if I chose to only run it in the administration area, or on site front-end, would that fix the problem (with the code that is above)?

    Plugin Author Shea Bunge

    (@bungeshea)

    Hi @jason975,

    When I said “run everywhere”, the distinction was not which parts of your site it would run on, but rather that snippets are all run before the page is loaded. As the snippet you posted produces content directly, it’s unclear where exactly on your site the content it supposed to go. Snippets are less for including arbitrary HTML/PHP code and more for including code that you would otherwise put in a plugin or a functions.php file.

    Thread Starter jason4locations

    (@jason975)

    Thank you, Shea Bunge. With the Code Snippets plugin, is there a way to put the code in a theme, not WordPress? If not, is there a way to? The reason why I’m asking is because I’m trying to remove a search form that I’m guessing comes from a theme, not WordPress. Should this be a different topic?

    Plugin Author Shea Bunge

    (@bungeshea)

    Not necessarily, no. The code isn’t actually ‘injected’ anywhere, it just runs on your site as if it was in a plugin.

    If you’re using a theme that makes good use of action and filter hooks, there’s a lot you can accomplish through snippets. Themes that are less well-built will be a lot more limiting.

Viewing 14 replies - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.