Use WP_Query with Taxonomy Parameters. If you want posts that are in both categories, just add two conditions in tax_query (using an array for terms
will get you posts that have at least one of those categories).Note that you'll have to adapt the taxonomy to your needs. Instead of slug
, you could also use term_id
, term_taxonomy_id
or name
as the field to be searched.
$query = new WP_Query( array('tax_query' => array( array('taxonomy' => 'mytaxonomy','field' => 'slug','terms' => "females" ), array('taxonomy' => 'mytaxonomy','field' => 'slug','terms' => "sport-fitness" ), ), ));