1
How to return all post_type linked to a taxonomy?
1
How to return all post_type linked to a taxonomy?
2
Fast way:
Assuming your taxonomy is "people" and the person you want to search for is "bob":
$args = array(
'post_type' => 'post',
'pessoas' => 'bob'
);
$query = new WP_Query( $args );
Another way to do the same thing...
$args = array(
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'pessoas',
'field' => 'slug',
'terms' => 'bob'
)
)
);
$query = new WP_Query( $args );
It is also valid to search in more than one taxonomy:
$args = array(
'post_type' => 'post',
'pessoas' => 'bob',
'language' => 'english'
);
$query = new WP_Query( $args );
It’s all in the Codex
1
Only use the following code and change the $type variable to the name of your taxonomy.
$type = 'nomedataxonomia';
$args=array(
'post_type' => $type,
'post_status' => 'publish',
'posts_per_page' => -1,
);
$my_query = new WP_Query($args);
while ($my_query->have_posts()){
$my_query->the_post();
}
0
The question has little information, but from what I understand you need to list posts (regardless of the type, if post, page or other that you created), then on Codex we have the following suggestion:
<?php
$args = array(
'posts_per_page' => 5,
'offset' => 0,
'category' => '',
'orderby' => 'post_date',
'order' => 'DESC',
'include' => '',
'exclude' => '',
'meta_key' => '',
'meta_value' => '',
'post_type' => 'post',
'post_mime_type' => '',
'post_parent' => '',
'post_status' => 'publish',
'suppress_filters' => true
);
?>
Browser other questions tagged php wordpress
You are not signed in. Login or sign up in order to post.
With SQL or some native Wordpress function?
– Rodrigo Rigotti