• Resolved jennjoanne

    (@jennjoanne)


    On the posts that I use your plugin – insert pages – it looks as though it is pulling information from another plugin I use – Bottom of every post – and I can’t figure out how to make it stop doing that because then that information ends up appearing twice in my posts.

    The plugin – Bottom of every post – adds my social media and email subscription information to the bottom of every post. It does not add that information to the bottom of pages. It works fine on posts that do not use Inserted Page.

    An example of a post with Inserted Pages and my social media info showing twice is:
    https://starcrossedbookblog.com/2014/10/anew-the-archers-of-avalon-1-by-chelsea-fine/

    I love your plugin but would greatly appreciate direction in how to resolve this since I’ve looked into the code and can’t figure out what I need to change. Thank you!
    Jen

    https://www.ads-software.com/plugins/insert-pages/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Paul Ryan

    (@figureone)

    Looks like the “Bottom of every post” plugin hooks into the_content filter and prints the contents of that bottom_of_every_post.txt file in the plugin directory every time the_content() is called.

    If you want to continue using that plugin but you don’t want the info printed on inserted pages, you can create a custom template that you use for inserted pages that unregisters the buttom_of_every_post filter that’s attached to the_content.

    remove_filter() is the function you’re looking for:
    https://codex.www.ads-software.com/Function_Reference/remove_filter

    So in your custom template you’d have something like this before calling the_content():
    remove_filter( 'the_content', 'bottom_of_every_post' );

    Thread Starter jennjoanne

    (@jennjoanne)

    Well, the latest update ended up fixing this issue. But thank you for informing me how to proceed, in case I need to take that route in the future.

    Hey figureone,

    I actually just stumbled upon the same issue that Jen has with the same plugin. Unfortunately the recent plugin update didn’t fix the issue for me, however.

    What you mentioned by creating a new page template, is it possible to include this in the general post template php file to apply to all posts? I ask because I wouldn’t be able to go back through the thousands of posts that we have and change the page type.

    So would I add this line
    remove_filter( 'the_content', 'bottom_of_every_post' );
    before the content is called within the single post template, and that should work, correct?

    Thanks for your help, sorry I am not that good at PHP.

    Thanks,
    Matt

    Hey figureone,

    I actually took a look at your comment again and I think I semi-understand it. I went ahead and created a custom page template within my theme, and then added
    remove_filter( 'the_content', 'bottom_of_every_post' ); before the_content was called.

    I then went back and changed the two pages that I’m pulling in content from to that template, and unfortunately no luck. It is still pulling in the text from bottom of every post.

    I actually tried to do this on my general posts.php template that controls all posts on my theme, and I placed it before the_content and it worked, however it worked to the extent where it was actually removing the small snippet that I need at the bottom of every post as well.

    Any suggestions?

    Thanks for your help,
    Matt

    Thread Starter jennjoanne

    (@jennjoanne)

    Matt –

    I haven’t tried it yet, since I no longer need to. But I did read that this is the correct way to set up page templates:

    https://codex.www.ads-software.com/Page_Templates#Custom_Page_Template

    and then from what figureone states:
    So in your custom template you’d have something like this before calling the_content():
    remove_filter( ‘the_content’, ‘bottom_of_every_post’ );

    If the above doesn’t work correctly, I’d recommend starting a new thread in the How-To and Troubleshooting since I have gotten great help in the past there:
    https://www.ads-software.com/support/forum/how-to-and-troubleshooting

    Thanks for the response, Jenn.

    Yeah, I went through and made a custom page template, removing the filter before thecontent was called, and no luck.

    Hopefully I can get this figured out soon as insert pages is a huge time saver for me, but so is bottom of every post.

    Thread Starter jennjoanne

    (@jennjoanne)

    Sorry I couldn’t be more help. Lots of luck! =D

    Plugin Author Paul Ryan

    (@figureone)

    Hm, looking at the remove_filter() documentation, looks like it’s hard to remove filters created by other plugins:

    If a filter has been added from within a class, for example by a plugin, removing it will require accessing the class variable.

    https://codex.www.ads-software.com/Function_Reference/remove_filter

    Plugin Author Paul Ryan

    (@figureone)

    mattvd, the latest update (2.2) includes a new method for disabling the_content filter on inserted pages. Since bottom of every post hooks into the_content filter to add its content, you can use this new method to get what you want.

    Note that I had to revert the automatic change that I applied in v2.1 because it was affecting others negatively. So you’ll need to do this manually. An example is below.

    You can add the following code to your theme’s functions.php to disable the_content on inserted pages:

    // Disable the_content filter for inserted pages.
    function theme_init() {
        add_filter( 'insert_pages_apply_the_content_filter', function ( $should_apply ) { return false; } );
    }
    add_action( 'init', 'theme_init' );
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Pulling information not wanted into inserted page’ is closed to new replies.