• SgrWd

    (@adamf24)


    Is there a way to exclude categories from the php get_archives function? I looked under the get_archives page on www.ads-software.com but I didn’t see anything about excluding categories.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter SgrWd

    (@adamf24)

    Anyone?

    moshu

    (@moshu)

    Well, if there isn’t such parameter listed in the Codex… it means it doesn’t exist.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    I’m not certain I understand the question. What do you mean by “exclude categories”, exactly? How does that that relate to the get_archives function?

    Thread Starter SgrWd

    (@adamf24)

    Well get_archives will list the most recent posts. What I am asking is if you can set the get_archives function to list the most recent posts, but exclude any recent posts that fall under a category I wish to exclude from listing.

    moshu

    (@moshu)

    No, you can not.
    Use a recent_posts gizmo (plugin, widget, etc.) for that.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Well get_archives will list the most recent posts.

    No, it doesn’t. get_archives (and wp_get_archives) produce a list of links to the archive pages. Like the monthly archives and such.

    https://codex.www.ads-software.com/Template_Tags/wp_get_archives

    I guess that’s why I’m confused, you’re apparently using the wrong terminology here. Either that, or you are very specifically talking about the “postbypost” type. In which case, read moshu’s answer above. You could possibly do it with a custom filter on ‘getarchives_join’, but frankly it’d be simpler to use get_posts and write a simple loop instead.

    im facing the same problem. i list a monthly archive. AFTER I click a month in my archive list, it will display the entries I made in that month. I want to exclude a certain category from those results.

    i would have used

    <?php if ( in_category(17) ) {
    echo ' <div style="display: none;">';
    }
    ?>

    but i still actually want that category of entries to appear for “daily” archives.

    This is actually pretty easy, and the answer is in the codex

    after the “if(have_posts():…the_post();” just add:

    if(in_category(‘NUMBER HERE’)) continue;

    That’s all there is to it.

    kdkaushik

    (@kdkaushik)

    Hi i have the same problam

    im facing the same problem. i list a monthly archive. AFTER I click a month in my archive list, it will display the entries I made in that month. I want to exclude a certain category from those results.

    i would have used

    <?php if ( in_category(17) ) {
    echo ‘ <div style=”display: none;”>’;
    }
    ?>but i still actually want that category of entries to appear for “daily” archives.

    the solution here is looking best but i donot know How to use these codes

    <?php if ( in_category(17) ) {
    echo ' <div style="display: none;">';
    }
    ?>

    and
    if(in_category('NUMBER HERE'))

    Thank you in advance…

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Excluding categories from Get_Archives’ is closed to new replies.