• Resolved DFL77

    (@dfl77)


    There are a few certain posts on my site that I DO NOT want to display related posts on. So I want to be able to use the shortcode on all other posts and also manually choose the related posts that are displayed.

    When using the shortcode though, it displays random related posts instead of the posts that I manually choose on the “Edit Post” page. Is there a way to correct this?

    If not, is there a function I can run to EXCLUDE certain posts from displaying related posts at the bottom when selecting “enable related post automatically for post”?

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Yes, you can filter query arguments for related posts, please check this documentation
    https://pickplugins.com/documentation/related-post/filter-hook/related_post_query_args/

    Regards

    Thread Starter DFL77

    (@dfl77)

    Excellent, thank you!

    Hello, I want to exclude posts having only 1 specific category from showing in related posts. for example, if the post has categories “a” and “b”, I want to exclude category “a” from showing so I used this code according to the previous link:

    add_filter(‘related_post_query_args’,’related_post_query_args_20200126′);

    function related_post_query_args_20200126($args) {

    // exclude categories
    $args[‘category__not_in’] = array(3748);//3748 is id for category b

    return $args;
    }

    But the problem is no related posts are showing even if the post has a category “b”.
    Any help would be appreciated!
    Thank you!

    • This reply was modified 2 years, 4 months ago by bdeirhiba990.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Manually Choose Related Posts With Shortcode?’ is closed to new replies.