• Resolved sadlerjw

    (@sadlerjw)


    Hi! I want to exclude all micro-blog type posts from my archive, which are denoted in my site by a certain category. (Regular posts only have the “Uncategorized” category, which, unfortunately, all the micro-blog posts also have. Whoops.)
    My expectation is that when I use the shortcode:

    [SimpleYearlyArchive type="yearly" exclude="30"]

    That it will disallow any posts that have category 30. However, from reading the code it looks like it just subtracts that category from the list of categories to consider. But since the remaining category (“Uncategorized”) also contains all the posts in category 30, the exclusion makes no actual change.

    From reading some of the WP docs, it looks like you can pass negative category IDs into get_posts, which would presumably produce the desired effect. So instead of starting with all categories ([1, 30]) and subtracting 30, giving [1], you could supply [1, -30] or simply [-30] and let WordPress take care of the filtering for you.

    In the meantime, I’ve worked around this by using:

    [SimpleYearlyArchive type="yearly" include="-30"]

    Thanks!
    Jason

    • This topic was modified 6 years, 7 months ago by sadlerjw.
  • The topic ‘Use standard WordPress rules for category exclusion’ is closed to new replies.