• I’m trying to query the posts by category

    <?php query_posts( ‘cat=-12&orderby=category&order=DESC’ ); ?>

    However, what it puts out seems totaly random….The numbers are the category ID & theater is the category name….

    # Sucker Punch

    * Theater 4

    17March 22, 2011

    # Limitless

    * Theater 3

    16

    # The Lincoln Lawyer

    * Theater 2

    15

    # Diary of a Wimpy Kid 2

    * Theater 1

    14

    # Red Riding Hood

    * Theater 6

    19

    # Paul

    * Theater 5

    18

    # Mars Needs Moms

    * Theater 4

    17March 18, 2011

    # Paul

    * Theater 1

    14

    # The Adjustment Bureau

    * Theater 6

    19

    # Battle: Los Angeles

    * Theater 3

    16

Viewing 8 replies - 1 through 8 (of 8 total)
  • There’s no orderby=category in query_posts.

    Thread Starter salesbcocom

    (@sales4bcocom)

    Well, that would explain why it doesn’t work…. What code should I use to get it to order by the category…. I just saw that code in lots of places on this site, guess that why other people had problems too.

    Thread Starter salesbcocom

    (@sales4bcocom)

    Yes, I’ve read that & found no reference on how to make the posts sort by category

    That’s because there isn’t an option to order by category. The only way to do this would be to have multiple Loops – each calling one category at a time.

    Thread Starter salesbcocom

    (@sales4bcocom)

    Well, I need to query posts not in category 12. They need to be sorted by date first, then by category. Can you give me any more specifics on how to make this happen?

    That is going to take a lot of work. You’d need to grab the results of the standard query (as opposed to displaying it) and then start looping through it to pull out/display posts from a specific category. Then repeat for every category that you want to display.

    Thread Starter salesbcocom

    (@sales4bcocom)

    Ok…I have my code narrowed down & closer to what I want. Hoping someone can help me finalize it

    Need to first query the posts to only pull in those whose movieStartDate value is less than or equal to today….then have it loop through the code to sort by category

    ****query_posts (meta_key=’movieStartDate’&meta_value<=time())

    [Code moderated as per the Forum Rules. Please use the pastebin]

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Query posts by category ~ not working’ is closed to new replies.