Product listing based on Custom Taxonomy
-
Hello,
Greetings of the day!
I am a WordPress developer currently using your Woo-commerce plugin to my new website. On query of default product category listing page I want to add some custom arguments like some taxonomy Id which will display the product listing on the basis of newly constructed taxonomy code.Taking an example to clarify the doubt: –
add_filter(‘pre_get_posts’,’better_editions_archive’);
function better_editions_archive($query) {
if ( $query->is_main_query() ) {
$query->set( ‘post_type’, array( ‘product’ ) );
$query->set( ‘tax_query’,
array(
array(
‘taxonomy’ => ‘multi_vendor’,
‘field’ => ‘id’,
‘terms’ => array( 6, 7, 8 ),)
)
);}
return $query;
}I used this code in theme’s function.php file but it is not working.
A help from any expert will be highly appreciated.
- The topic ‘Product listing based on Custom Taxonomy’ is closed to new replies.