Support

Home Forums Event Espresso Premium Using category in query_posts

Using category in query_posts

Posted: August 18, 2014 at 4:48 pm


Christina Morris

August 18, 2014 at 4:48 pm

What is wrong with this? It isn’t returning my category, only the most recent events. What am I missing?
EE4, WP version current, site: http://50.87.39.161/~bgcdalla/ (for the front page, lower left corner)

query_posts(array('post_type' => 'espresso_events', 'posts_per_page' => 4, 'category_name' => 'current' ));

Thanks in advance!
Chrisitna


Josh

  • Support Staff

August 18, 2014 at 7:44 pm

Hi Christina,

It turns out that the taxonomy term for Espresso Events is ‘espresso_event_categories’.

As an aside, WP_Query or get_posts are recommended and it’s usually recommended to avoid using query_posts.


Christina Morris

August 19, 2014 at 7:46 am

Still no joy. What is the expected answer? the slug, the name, the ID?
It returns everything anyway!
Thanks

Thanks for the aside, not my theme. When I change it to WP_Query it conflicts with something else and the loop gets stuck. Don’t have time to troubleshoot, today.


Josh

  • Support Staff

August 19, 2014 at 8:13 am

Hi Christina,

Can you post the template file in a gist or a pastebin so we can see the code in context? Thanks.


Christina Morris

August 19, 2014 at 8:21 am

Thanks!!
http://pastebin.com/E9QjHeV2


Josh

  • Support Staff

August 19, 2014 at 8:39 am

Hi Christina,

I ran the code and it works if I use the slug:

'espresso_event_categories' => 'event-category-slug'

Along with that, you will need to include the event template view helper before you start the event loop. You can include the view helper by adding this line of code before the query:

load_helper('Event_View'); ?>

The support post ‘Using category in query_posts’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso