Support » Plugin: Related Posts by Taxonomy » Shortcode works, do_shortcode or theme functions do not

  • Resolved kontur



    when I use the shortcode in the end of a post the plugin correctly renders some related posts.

    However, when I try to integrate the shortcode to my article template, neither do_shortcode() nor km_rpbt_related_posts_by_taxonomy() seem to work (for the same exact post). Inside the loop I have tried both of these like so:

    <?php var_dump($post->ID); ?>
    <?php do_shortcode('[related_posts_by_tax post_id="' . $post->ID . '"]'); ?>
    <?php km_rpbt_related_posts_by_taxonomy($post->ID, 'category'); ?>

    I get the correct post ID output to the page, but no related posts or errors.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author keesiemeijer



    Hi kontur

    Are you echoing the shortcode?

    <?php echo do_shortcode('[related_posts_by_tax post_id="' . $post->ID . '"]'); ?>

    *facepalm* Thanks, solved 🙂

    Very nice plugin, thank you for the work!

    Plugin Author keesiemeijer



    You’re welcome 🙂

    The shortcode works for me, but the function is returning an empty array:

    $taxonomies = array('project_categories', 'service_categories');
    $has_related = km_rpbt_related_posts_by_taxonomy($post->ID, $taxonomies);

    a var_dump of the function gives me:

    array(0) {}

    Any thoughts?


    I needed to pass the correct post type in the args. Nevermind 🙂

    • This reply was modified 1 month, 3 weeks ago by  .
    • This reply was modified 1 month, 3 weeks ago by  .
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.