Here's what I have:
Custom Post type: Vendors
Vendor categories:
- Wedding
- Party
- Catering
I want to query all Vendors and then assign them a class based on the category they are in. The class would be .wedding if they are categorized as wedding and .party for party and so on.
$args = array(
'post_type' => 'vendors',
'order' => 'asc',
'orderby' => 'title',
);
$query = new WP_Query( $args );
So that grabs the posts in order by title. I want to add the class based off of their category and echo them as a list item as so:
<ul>
<li class=".category">TITLE</li>
<li class=".category">TITLE</li>
<ul>
I also want to query from the posts and categories that are made in Wordpress, not from some pre-defined list since this will be changing every now and then. I know I'll want to do a foreach loop but I'm not sure how to find their taxonomy and echo it as a class.
TITLE
the category title or post title? Do you even need posts or just categories? Is there a specific class you want or do you want each category to have a unique class ( think slug ) ?