WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Hiding plugins on pages (5 posts)

  1. LizStabbert
    Member
    Posted 2 years ago #

    So I just installed this nifty Pinterest plugin but it's showing up on my pages as well as my posts http://blog.lizstabbertphoto.com/about/ There isn't an option to remove it from pages in the plugin settings unfortunately. How can I go about this?

  2. That plugin adds the button to the_content via add_filter.

    Try this: Create a new file called remove-pin-it.php and put it in the wp-content/plugins directory.

    In that file put these lines.

    <?php
    /*
    Plugin Name: Remove Pinterest Button from Pages
    */
    
    add_filter( 'the_content' , 'liz_remove_pin_it_button' , 30 );
    function liz_remove_pin_it_button( $content ) {
    if ( is_page() ) {
       remove_filter("the_content", "add_pin_it_button");
    }

    Go into your Dashboard and activate that plugin. It should check if the_content is inside a page and remove the Pinterest button from pages only.

    If something goes Really Wrong™ then just delete that new file remove-pin-it.php.

  3. LizStabbert
    Member
    Posted 2 years ago #

    That gave me a blank page and the error
    "Parse error: syntax error, unexpected $end in /home/content/59/6174659/html/blog/wp-content/plugins/remove-pin-it.php on line 10" until I deleted the file :-o

  4. Whoops, did I screw that up, sorry. I'll make up for that. :)

    I just installed the Pinterest plugin on my Crash Test Dummy blog and came up with this fix.

    <?php
    /*
    Plugin Name: Remove Pinterest Button from Pages
    */
    
    add_action( 'loop_start' , 'liz_remove_pin_it_button' );
    function liz_remove_pin_it_button() {
       if ( is_page() ) {
          remove_filter("the_content", "add_pin_it_button");
       }
    }

    Before I was trying to remove a filter from within the content that the filter was being applied. That won't work.

    ...Also I left off a closing } which caused that error...

    This new one worked for me and should work for you too. It only removes the button on pages and nothing else.

  5. LizStabbert
    Member
    Posted 2 years ago #

    Rock on! Worked perfectly! Thanks so much!

Topic Closed

This topic has been closed to new replies.

About this Topic