Support » Plugin: Related Posts by Taxonomy » Not posting on Pages

  • Resolved jailavie


    Hello – I got related posts by category to successfully show on my posts via the widget. However I also want to add to PAGES. I can’t seem to get this to work – I added the shortcode on this page but nothing shows:
    Do I have to do something different to add to a page vs a post?


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

Viewing 9 replies - 1 through 9 (of 9 total)
  • Never mind I figured out I did not have a post id attributed to pull in. Thanks!

    Ah now I’m still having trouble. I want the page to display related posts based on a specific category, but the page itself isn’t part of the category. Can I do this? The support doc mentions term id, but I don’t see anywhere to find that… Here is my page:

    Plugin Author keesiemeijer



    Hi jailavie

    Sorry for the late reply. Pages (post type) with taxonomies should work for the shortcode. For the widget you can add support to it by implementing this:

    Let me know if this is not the issue

    Thank you – that added the ability to add the widget to pages, but since my template only puts widgets on posts and not pages, I still have to use the short code. The short code I added to this page will not pull in related posts based on category. (I have my pages categorized into the same categories as my posts.)

    On my page the shortcode works if I add in a post id to reference:
    [related_posts_by_tax title=”Read More About This Country” post_id=”2638″ image_size=”medium” format=”thumbnails” posts_per_page=”-1″]

    However when I remove the post id, it doesn’t work. The problem with using the post id is that I want that particular post (2638) to show as well. There are 4 stories total in the France category. So I would prefer it to pull in ALL related posts that are in the “France” category. Is that possible?

    Plugin Author keesiemeijer



    If I understand it right you want to pull in related posts from another page and include that page in the results.

    Try it with this in your child theme’s functions.php

    add_filter( 'related_posts_by_taxonomy', 'rpbt_include_post', 10, 4 );
    function rpbt_include_post( $results, $post_id, $taxonomies, $args ) {
    	if ( ! $results ) {
    		return $results;
    	$post = get_post( $post_id );
    	if ( $post ) {
    		array_unshift($results, $post);
    	return $results;

    This will add the post to the related posts found.

    consider creating a child theme instead of editing your theme directly – if you upgrade the theme all your modifications will be lost. Or create a plugin with the code above.

    Thank you I figured it out! I added post_types=”posts,pages”instead of the post id itself. Thanks!


    hi @jailavie
    i have same problem with theme twenty fourteen…
    can you plz post the whole shortcode you worked out for U?
    so you put a shortcode in sidebar code because your theme doenst have widgetsupport for pages just for posts…?

    Hey @rmblfish – Sure, here you go:

    [related_posts_by_tax title="Read More About This Country" post_types="posts,pages" image_size="medium" format="thumbnails" posts_per_page="-1"]

    I think you need post_types=”posts,pages” for it to work across both pages and posts. I wanted the ability for PAGES to pull in related POSTS so this worked for me. Hope it helps.

    Here’s an example live:


    • This reply was modified 6 months, 2 weeks ago by  jailavie.
    Plugin Author keesiemeijer



    Hi @jailavie

    Thanks for answering here 🙂

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Not posting on Pages’ is closed to new replies.