Ich habe diesen Code auf meiner WordPress-Site, der Produkte anzeigt, die ich habe:
<?php
$params = array('posts_per_page' => 5, 'post_type' => 'product');
$wc_query = new WP_Query($params);
?>
<ul>
<?php if ($wc_query->have_posts()) : ?>
<?php while ($wc_query->have_posts()) :
$wc_query->the_post(); ?>
<li>
<h3>
<a href="https://stackoverflow.com/questions/50802271/<?php%20the_permalink();%20?>">
<?php the_title(); ?>
</a>
</h3>
<?php the_post_thumbnail(); ?>
<?php the_excerpt(); ?>
</li>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<li>
<?php _e( 'No Products' ); ?>
</li>
<?php endif; ?>
</ul>
Es funktioniert gut, aber ich möchte Produkte aus der von mir gewählten Kategorie anzeigen, wie kann ich das tun?