• Resolved kattouf

    (@kattouf)


    Many of my posts are members of two categories. “Featured (id 2)” and “Specific category(id 3,4 etc)”. The Featured ones get shown on the homepage.

    I want to show a list of latest posts per category when reading the post, but not show all the Featured ones, because featured ones can be in other categories too.

    I am using this: categorypage=”yes” id=’-2′

    However, since the post is member of 2 and 3, it is not excluding posts from 2.

    any ideas?

    thanks

    /J

    https://wordpress.org/plugins/list-category-posts/

Viewing 1 replies (of 1 total)
  • Thread Starter kattouf

    (@kattouf)

    Solved:

    It’s not elegant but this is ONE way that works:

    <?
    foreach((get_the_category()) as $category) {
        $thiscat= $category->cat_ID ;
    $thiscat= $thiscat.",";
    $thiscat = preg_replace('/(?<=^|,)\b2\b(?=,|$)/', '', $thiscat);
    }
    ?>

    Shortcode: <? echo do_shortcode("[catlist id='".$thiscat."']");?>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been damaged by the forum’s parser.]

    If you know a lighter code let me know!

Viewing 1 replies (of 1 total)
  • The topic ‘Post in two Categories – exclude one when displaying’ is closed to new replies.