Dynamic variable for custom taxonomy in loop?

You could let your client add the product category via a custom field.

<?php $loop = new WP_Query( array( 'post_type' => 'product_listing', 'product_cat' => get_post_meta($post->ID, 'product_cat', true), 'posts_per_page' => 4 ) ); ?>

This should work if your client adds a custom field value for the key ‘product_cat’.

Leave a Comment