Created
December 23, 2015 05:40
-
-
Save vladimirlukyanov/2d39d4bd42cf6343ef38 to your computer and use it in GitHub Desktop.
Get dropdown list of products WooCommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$args = array( | |
'post_type' => 'product', | |
'post_status' => 'publish', | |
'ignore_sticky_posts' => 1, | |
'posts_per_page' => '12', | |
'meta_query' => array( | |
array( | |
'key' => '_visibility', | |
'value' => array('catalog', 'visible'), | |
'compare' => 'IN' | |
) | |
) | |
); | |
$products = new WP_Query($args); | |
print '<select>'; | |
while ($products->have_posts()) : $products->the_post(); | |
print '<option value="' . get_the_ID() . '">' . get_the_title() . '</option>'; | |
endwhile; | |
print '</select>'; | |
wp_reset_query(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment