Last active
August 28, 2019 01:21
-
-
Save camilolunacom/76a1040d95d7fc9de947386376a9f838 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
function productos_nuevos_shortcode() { | |
$args = array( | |
'post_type' => 'product', | |
'posts_per_page' => -1, | |
'orderby' => 'menu_order', | |
'meta_key' => 'nuevo', | |
'meta_value' => '1' | |
); | |
$loop = new WP_Query( $args ); | |
if ( $loop->have_posts() ) { | |
echo '<div class="woocommerce columns-4"><ul class="products columns-4">'; | |
while ( $loop->have_posts() ) : $loop->the_post(); | |
wc_get_template_part( 'content', 'product' ); | |
endwhile; | |
echo '</ul></div>'; | |
} else { | |
echo __( 'No products found' ); | |
} | |
wp_reset_postdata(); | |
} | |
add_shortcode('productos_nuevos', 'productos_nuevos_shortcode'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment