WordPress.org

Ready to get started?Download WordPress

Forums

Maintain the post order according to category name in WP_Query? (6 posts)

  1. susheel kumar
    Member
    Posted 1 year ago #

    Can we have post order according to the category name in WP_Query or query_posts().

  2. esmi
    Forum Moderator
    Posted 1 year ago #

    No. All available orderby options are listed in this Codex section. what is it that you are trying to do? List posts according to categories - ie Cat 1 posts followed by Cat 2 posts etc?

  3. susheel kumar
    Member
    Posted 1 year ago #

    Yes exactly. I want to order posts by category something like this
    cat1
    post1
    post2
    post3
    cat2
    post1
    post2
    post3
    ---
    ---
    Is it possible by using simple wp_query() or i have to get the categories then loop through the category id. But in this case i have another issue with pagination.

  4. esmi
    Forum Moderator
    Posted 1 year ago #

    You'll need to use the second option - grab the categories and then step through them launching a new query & Loop for each category. And, yes, I can see how that's going to create a pagination issue but I don't think there's any other way of doing this.

  5. susheel kumar
    Member
    Posted 1 year ago #

    Thanks for your support esmi.

  6. Sachin Mishra
    Member
    Posted 1 year ago #

    I have the same problem but I have got the posts by category. Still facing issue for paging.

    :(

Topic Closed

This topic has been closed to new replies.

About this Topic