/ Published in: PHP
                    
                                        
Filter products based on their category
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
add_action('pre_get_posts','shop_filter_cat');
function shop_filter_cat($query) {
$parentt=$query->queried_object->post_parent;
$titlee=$query->queried_object->post_title;
if (!is_admin() && $parentt==9773 && $query->is_main_query()) {
'field' => 'slug',
'terms' => $titlee
)
)
);
}
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                