Skip to content

Instantly share code, notes, and snippets.

@luanpiegas luanpiegas/shortcode.php
Last active Jul 21, 2016

Embed
What would you like to do?
Snippet para shortcode do Wordpress
<?php
function shortcode_mostra_produtos ( $atts ) {
$atts = shortcode_atts( array(
'default' => ''
), $atts );
$terms = get_terms('linhas');
wp_reset_query();
$args = array('post_type' => 'produtos',
'tax_query' => array(
array(
'taxonomy' => 'linhas',
'field' => 'slug',
'terms' => $atts,
),
),
);
$loop = new WP_Query($args);
if($loop->have_posts()) {
while($loop->have_posts()) : $loop->the_post();
echo ' "'.get_the_title().'" ';
endwhile;
}
}
add_shortcode( 'produtos','shortcode_mostra_produtos' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.