Skip to content

Instantly share code, notes, and snippets.

@jpcontrerasv
Created July 30, 2014 14:53
Show Gist options
  • Save jpcontrerasv/192ab46848a80581590d to your computer and use it in GitHub Desktop.
Save jpcontrerasv/192ab46848a80581590d to your computer and use it in GitHub Desktop.
WP > Wp_queries
<?php $var_destacados = new WP_Query('post_type=destacados&showposts=6'); while ($var_destacados->have_posts()) : $var_destacados->the_post(); ?>
<?php endwhile; ?>
/*con taxonomias*/
<?php
query_posts( array(
'post_type' => 'video',
'taxonomy' => 'programas',
'term' => 'la-escul',
'posts_per_page' => 4,
'cat' => '-204'
));
if (have_posts()) :
while (have_posts()) : the_post();
?>
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?>
/*Excluir taxonomia del post type */
<?php
query_posts( array(
'post_type' => 'video',
'posts_per_page' => 4,
'cat' => '-204',
'tax_query' => array(
array(
'taxonomy' => 'programas',
'field' => 'slug',
'terms' => 'la-escul',
'operator' => 'NOT IN')
),
));
if (have_posts()) :
while (have_posts()) : the_post();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment