• Resolved kontur

    (@kontur)


    Hey,

    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

    (@keesiemeijer)

    Hi kontur

    Are you echoing the shortcode?

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

    (@kontur)

    *facepalm* Thanks, solved ??

    Very nice plugin, thank you for the work!

    Plugin Author keesiemeijer

    (@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 6 years, 8 months ago by wadehammes.
    • This reply was modified 6 years, 8 months ago by wadehammes.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Shortcode works, do_shortcode or theme functions do not’ is closed to new replies.