Skip to content

Instantly share code, notes, and snippets.

@alandbh
Last active April 18, 2017 15:21
Show Gist options
  • Save alandbh/3e4463619c499d9b6174a4fedfebeb3d to your computer and use it in GitHub Desktop.
Save alandbh/3e4463619c499d9b6174a4fedfebeb3d to your computer and use it in GitHub Desktop.
It get posts by taxomony terms. // Pega posts pela taxonomia
function feed_cidades($categoria) {
if ($categoria == '') {
$args = array (
'post_type' => 'cidades', //it can be other
'posts_per_page' => '-1'
//'post__not_in' => array($exclude)
);
} else {
$args = array (
'post_type' => 'riquezas', //it can be other
'posts_per_page' => '-1',
//'post__not_in' => array($exclude),
'tax_query' => array(
array(
'taxonomy' => 'regiao',
'field' => 'slug',
'terms' => $categoria,
),
)
);
}
if ($categoria == 'natureza') {
$texto = 'Retranca natureza';
} elseif ($categoria == 'pessoas') {
$texto = 'Retranca pessoas';
}
// The Query
$postagens = new WP_Query( $args );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment