I wanted to get some advice on how to list all my inventory attributes values. I have this simple code that will output the products as plain text, But instead of
the_title(); I want a list of all products by their attribute's values. So, if a product has attribute carat it will be listed as follows:
carat 0.32 0.41 2.3 3.3
A product has attribute color and another product has attribute carat and they will be listed as
red 0.32 blue 0.32 0.41 2.3 3.3
Basically, I want to know how to do it for multiple attributes to get their values, cuz bottom line the title of my products are the same values concatenated together.
Right now, I am only getting a list of titles, but I want a list of attributes' values.
<?php $params = array('posts_per_page' => 5, 'post_type' => 'product'); $wc_query = new WP_Query($params); ?> <?php if ($wc_query->have_posts()) : ?> <?php while ($wc_query->have_posts()) : $wc_query->the_post(); ?> <?php the_title();?><br> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <?php else: ?> <p><?php _e( 'No Products' ); ?></p> <?php endif; ?>
Thanks all for viewing this.