WordPress.org

Ready to get started?Download WordPress

Forums

WP_Query, showing specific category breaks sticky posts (4 posts)

  1. anttijn
    Member
    Posted 2 years ago #

    It seems that when you make a custom query like this one, the sticky posts in category 1 will not show up first like they should.
    $custom_query = new WP_Query('cat=1');

    However, if you exclude other categories, the sticky posts function correctly.
    $custom_query = new WP_Query('cat=-2,-3,-4');

    While I want to show just the posts from category 1 in this query, excluding other categories is not an option - the customer would have to edit the query everytime new categories are created.

    Any ideas how to use WP_Query('cat=1'); and still make the stickies work? In my opinion this is a bug, or is anyone else seeing similar behaviour?

  2. thetrickster
    Member
    Posted 2 years ago #

    I'm seeing the same exact thing. I have an alternate loop which i just want to show the latest posts from the "news" category INCLUDING sticky posts that are at the top of the list.

    So now, I have to edit that query everytime the staff adds a new category so I have a big messy list of all the categories NOT to include even though I'm only including one. Anytime I tried to use a simpler, more accurate query using "cat=9" the sticky posts are no longer showed. Anyone have any tips around this?

  3. vava720
    Member
    Posted 2 years ago #

    I've got exactly the same problem, there's nobody have a solution for that ? :(

  4. davebowker
    Member
    Posted 1 year ago #

    Same problem. No fix yet?

Topic Closed

This topic has been closed to new replies.

About this Topic