0

I have a WP_Query that outputs products from given Product category name. For each product list I would also like to link to the category of that product, but I'm not sure how.

My query:

<?php
$new_posts = new WP_Query([
  'product_cat' => 'printer',
  'post_type' => 'product',
  'orderby' => 'meta_value_num',
  'order' => 'DESC',
  'meta_key' => 'view_count',
  'posts_per_page' => 9,
]);
?>

Output link something like this:

  <a href="<?php echo $cat_id ?>" class="procat-link">More Products...</a>

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.