Home › Forums › General Issues › Filter category list › Reply To: Filter category list
Hi,
I’m not sure what you’re asking/doing, but I think you should use the proper WordPress way to set this up.
Create a custom post type (Movies), then create a custom taxonomy (Genres), connect the taxonomy to the custom post type. You can use the CPT UI plugin for this, this Movies&Genres is literally the suggested example when you create your first CPT & Taxonomy.
Once you have this connected, you will automatically get “checkboxes” under your Movies posts and you can set your genres per movie.
When you want to loop trough a Genre, just use a WP_Query that filters by custom taxonomy. Here’s an example of that code:
$args = array(
'post_type' => 'movies',
'tax_query' => array(
array(
'taxonomy' => 'genres',
'field' => 'slug', //can be set to ID
'terms' => 'action' //if field is ID you can reference by cat/term number
)
)
);
$query = new WP_Query( $args );
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.