Tagged: 

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #14530

    Dear Support,

    i’ve got two questions about the related-posts-function on post-pages:

    1) I would like to exclude two categories from the Related-Posts-Slider. How can I do so?

    2) The Related-Post-Function does not work on all posts.

    If a post got:

    no Tag -> no Related Posts (that’s normal for the moment. But probably it is possible to show any post randomly?)

    one Tag -Y sometimes related Posts / sometimes not

    more tags -> always Related Posts.

    What can I do?

    Best Regards

    Job

    #83816

    Hello,

    To exclude categories, open includes > related-posts.php. Find this code.

    $my_query = new WP_Query("tag=$tag_ids&showposts=$postcount&ignore_sticky_posts=1&orderby=rand");

    Add exclude category. Find the category ID to be excluded.

    $my_query = new WP_Query("tag=$tag_ids&showposts=$postcount&ignore_sticky_posts=1&orderby=rand&cat=-12,-34,-56");

    Regards,

    Ismael

    #83817

    Thanks Ismael! I will try that soon. Can you also say something about my second question?

    Best Regards

    Job

    #83818

    Hi Ismael,

    I wrote stupid things. I want to exclude tags not categories. Therefore I changed your code to this:

    $my_query = new WP_Query(“tag=$tag_ids&showposts=$postcount&ignore_sticky_posts=1&orderby=rand&tags=-59,-61,-62″);

    But that doesn’t really help. Any Ideas?

    Best regards

    Job

    #83819

    Hey,

    Try this. All posts without the tag ID 59, 61 and 62 will not be included.

    WP_Query("tag=$tag_ids&showposts=$postcount&ignore_sticky_posts=1&orderby=rand&tag__not_in => array( 59, 61, 62 )");

    Regards,

    Ismael

    #83820

    Hi Ismael,

    does it mean: All posts WITH this Tag-IDs will be Excludet or All posts WITHOUT this Tag-IDs will be excluded (that’s what i understood now).

    I whant to exclude this three Tag-IDs from the related posts.

    Sorry for interrupting you again!

    Best regards

    Job

    #83821

    Hello,

    My bad. All posts without this tag will be displayed. So it means that any posts with this tag will be excluded.

    Regards,

    Ismael

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Exclude Category from Related Posts’ is closed to new replies.