Skip to content

Instantly share code, notes, and snippets.

@leocaseiro
Created May 28, 2014 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leocaseiro/7e014f8165bf8ad066de to your computer and use it in GitHub Desktop.
Save leocaseiro/7e014f8165bf8ad066de to your computer and use it in GitHub Desktop.
<?php
$params = array('post_type' => 'garimpeiros', 'paged' => $paged);
if (isset($wp_query->query_vars['estado']) && '' != $wp_query->query_vars['estado'] ) :
$params['tax_query'] = array(
array(
'taxonomy' => 'estado',
'field' => 'slug',
'terms' => array($wp_query->query_vars['estado']),
)
);
endif;
$garimpeiras = new WP_Query($params);
?>
<ul>
<?php if ( $garimpeiras->have_posts() ) : while ( $garimpeiras->have_posts() ) : $garimpeiras->the_post(); ?>
<li><?php the_title(); ?></li>
<?php endwhile; else: ?>
<li><?php _e('Sorry, no posts matched your criteria.'); ?></li>
<?php endif; ?>
</ul>
@Villanuevand
Copy link

Hi Leocaseiro,
This gist return all post with the custom taxonomy "garimpeiros" right?

@leocaseiro
Copy link
Author

No, the taxonomy is estado and the custom post is garimpeiros!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment