I have a custom field in my categories using the checkboxes field. I want to make a page that will list categories that contain a specific checkbox field that is ticked. For example I have 3 checkboxes in my categories which are Romance,Action & Drama. I have ticked checkbox Action and I want to list categories on the page that have ticked checkbox Drama. What’s the easiest way to do this cause I’m not a programmer?
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 );