WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] wp_get_archives function... can I exclude a category? (12 posts)

  1. c0y0te
    Member
    Posted 6 years ago #

    The method of showing the most recent x posts on my theme is to use the wp_get_archives function. I've checked the codex (http://codex.wordpress.org/Template_Tags/wp_get_archives#Last_Twenty_Posts) for info on this but I don't see an answer so I'm asking the question here.

    Is it possible to exclude certain categories when using this function. In other words, can I retrieve all of my most recent X posts, excluding any from category Y. If so - can someone please post an example in code?

    All help greatly appreciated.

    c0y0te

  2. moshu
    Member
    Posted 6 years ago #

    If you don't see a category parameter in the Codex - it means there isn't.

  3. c0y0te
    Member
    Posted 6 years ago #

    So - any suggestions as to how I can achieve this then?

    I'm using EventCalendarV3 plugin and I've configured it to not display any events as posts (e.g. any posts using the events category). This works fine for the main page, but if I view any other 'pages' my recent-posts widget displays the events-related posts in the sidebar.

    All I want to do is not show any event related posts in my sidebar. How do I achieve this please?

  4. c0y0te
    Member
    Posted 6 years ago #

    anyone?

  5. c0y0te
    Member
    Posted 6 years ago #

    How about I try this a different way then...

    Is there any other way to display 'recent posts' without using the WP_GET_ARCHIVES function? In particular, a way where I can exclude posts from a category?

  6. c0y0te
    Member
    Posted 6 years ago #

    forget it

  7. MichaelH
    Member
    Posted 6 years ago #

    Take a look at Template_Tags/query_posts.

  8. tpitre
    Member
    Posted 6 years ago #

    Whoops! Nevermind, don't try tat...

  9. asfodel
    Member
    Posted 6 years ago #

  10. asfodel
    Member
    Posted 6 years ago #

    ^That solution didn't actually work. When I used it you could no longer visit a post, anything you clicked on would just take you to the index page.

  11. Ivovic
    Member
    Posted 6 years ago #

    what you guys want is either query_posts - or for something a bit lighter, get_posts, to make a custom list of posts while excluding categories.

    If you can't get either of those to work based on information in the Codex, then you're just not reading closely enough... they're extremely well tested and used by lots of people with great success.

  12. ryangrant
    Member
    Posted 6 years ago #

    this simple plugin worked for me

    http://justinblanton.com/projects/smartarchives/

Topic Closed

This topic has been closed to new replies.

About this Topic