Wow, that title got me all dizzy. It’s okay though, it’s not that complicated, right?
I just wanted to get this posted before I forgot what I did and where I did it. Since I use custom post types and custom taxonomies quite a bit, I need to reference this code quite a bit.
On the current site I’m working on, here’s what I have:
- Custom post type: Portfolio ( ‘portfolio’ )
- Custom taxonomy: Portfolio Categories ( ‘portfolio_cat’ )
- Portfolio category term archive: Media Analyst ( ‘media-analyst’ )
I put the following code in my taxonomy-portfolio_cat-media-analyst.php file.
WP_Query is extremely powerful, and the above code makes it easy for Genesis (affiliate link) to harness that power!
lucas says
I’m trying to put a custom loop together for an events CPT and this is a great snippet!
I’m using ACF for the CPT which has a field of event_date. What would be the “orderby” if I wanted my posts to display by order date? I’m sure this is simple, but I can seem to find it.
Thanks!
JiveDig says
Do you want the query to only include items that have a value in event_date? If so, you could add the meta_key to your query like ‘meta_key’ => ‘event_date’, and do orderby meta_value.
It gets tricky when you add custom fields to the query like that, but it definitely can happen. 😉