I would like to display a drop down menu for products in a category.
<select>
<option value="CODE HERE">Volvo</option>
</select>
So according to Wordpress coding..
<?php
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
Okay so I investigated further and I am looking to do a single page template according to https://developer.wordpress.org I am using a child theme for Storefront which is called NOVA WP.
To make this "single page template" I copied page.php and renamed it to page-buildit.php
This is Mypage in which I actually editing the code. I did copy the code but it turns out blank
found this: WooCommerce: Create a shortcode to display product categories but my undestanding is we cant do this anymore with the new wordpress version.
You can also use the function wp_dropdown_categories to make your code simpler. To get a dropdown of categories of products you can write like this.
Or if you want to hold the output in a variable you can use the argument 'echo'=>0 and then echo the variable to get the same output.
Check this out. This is the way to get product categories.!
Okay so here is how I solved it, with the help of Hemnath mouli, I already gave you the credit for the answer but I wanted to publish the products inside a category in a dropbox.
Now I will need to show the image of this product after selecting it.