Are you looking to create a taxonomy list using a custom query filter in WordPress? Custom query filters can be used to create a taxonomy list, which is a way of organizing and categorizing content based on specific criteria.
With the Taxonomy Listing block from the Nexter Blocks, you can easily create a taxonomy list based on a custom query filter.
To check the complete feature overview documentation of the Nexter Blocks Taxonomy Listing block, click here.
Requirement – This block is a part of the Nexter Blocks, make sure it’s installed & activated to enjoy all its powers.
For instance, we want to create a taxonomy list showing person id.
For this, you have to add some custom code. You can add the code in your Child theme function.php file or you can use plugins like Code Snippets to add your custom code or if you are using the Nexter theme you can use Nexter Extensions which comes with various extensions for your Theme including adding code snippets.
Note: This feature is for advanced users only. If you are comfortable with PHP only, then you should use it.
For example, we have added this code.
add_filter(‘tpgb_custom_taxo_query’, ‘tpgb_custom_taxo_query_function’,10,1);
function tpgb_custom_doc_query_function( $query_args ){
$query_args[‘meta_query’] = array(
‘relation’ => ‘OR’,
array(
‘key’ => ‘person_id’,
‘value’ => 73227,
‘compare’ => ‘=’
),
array(
‘key’ => ‘person_id’,
‘value’ => 970674,
‘compare’ => ‘=’
),
array(
‘key’ => ‘person_id’,
‘value’ => 17293,
‘compare’ => ‘=’
)
)
return $query_args;
}
Now to show person id based on this code, add the Taxonomy Listing block on the page, and select the appropriate style, layout and taxonomy
Then go to the Query tab and in the Custom Query ID field, add the filter key i.e. tpgb_custom_taxo_query here.
Now it will list the person id’s.