Support » Plugin: Insert Pages » “Related posts” showing underneath a page

  • Hi, I absolutely love this plugin. It has saved me so much time and frustration.
    But I have a question. I will go ahead and show you everything that many be germane to this, even involving other plugins.
    In the URL provided, if you hover over News, it shows the
    https://tranceam.org/news-menu/
    as expected – that is set using Max Mega Menu, but it also shows Related Posts underneath as well. And as it’s a page, it’s not supposed to do that.
    I have tried switching to Inline (the widgets show errors) and switching from Display: Content to Display: All, to no avail.
    I got around all this before with the Music menu item, but there were no widgets in there so it worked out OK.
    I have had this issue for years, and as I use Content Views Pro instead of the default WordPress version, along with some Content View snippet (I can just see people’s eyes glazing here, but just in case:)

    // Content Views Pro - show related posts for each post
    add_filter( 'the_content', 'cvp_theme_auto_show_related_posts', 999 );
    function cvp_theme_auto_show_related_posts( $content ) {
    	if ( is_single() ) {
    		ob_start();
    		echo do_shortcode( '[pt_view id="137d74a4v1" tag="GET_CURRENT"]' );
    		$content .= ob_get_clean();
    	}
    	return $content;
    }

    ,

    …I assumed it was gonna be too hard to pin down.
    So TL:DR, to solve my erroneous Related Posts showing problem, I am stymied by the widgets now working with Inline.
    Any thoughts?

    • This topic was modified 3 months, 2 weeks ago by machinelf.
    • This topic was modified 3 months, 2 weeks ago by machinelf.
    • This topic was modified 3 months, 2 weeks ago by machinelf.

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter machinelf

    (@machinelf)

    I have a feeling I’m gonna have to finally get/learn custom post types

    Thread Starter machinelf

    (@machinelf)

    I found a workaround. I had enabled pages to have tags, and be included in Related Posts, so if I remove all tags from the page, there are no Related Posts (I use a script to remove the “no Posts Found”)
    This is obviously not optimal but it will do for now until I learn more.

    Plugin Author Paul Ryan

    (@figureone)

    Check the example on the the_content hook page, they suggest checking is_main_query() and in_the_loop() in addition to is_single() to prevent adding in the extra content in subloops:
    https://developer.wordpress.org/reference/hooks/the_content/

    I think what’s happening is when the news page is inserted, the context for is_single() in your the_content callback is the parent page instead of the inserted page.

    Another option would be to try both insert methods (legacy and normal) in WordPress Dashboard > Settings > Insert Pages. The legacy one sometimes works better when alongside page builder plugins, but uses an older method that WordPress core no longer advises using.

    Hope that helps!

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