Reputation: 231
I have one custom post type:"videos", and i use the default tag for the videos post. Now i would like to get all the videos posts that have the same tags. First thing is to get all the tags, here is my code:
$tags =wp_get_object_terms( $post->ID, 'post_tag');
i also tried
$tags =the_terms( $post->ID, 'post_tag');
Both of them does not work. They return empty array().
I can see all the posts in dashboard by link:
videostags=ihealth&post_type=videos
Another question is can i get all the posts by tag id like this:
$args=array(
'tag__in' => 4,
'post__not_in' => array($post->ID),
'showposts'=>5,
'ignore_sticky_posts'=>1
);
$my_query = new WP_Query($args);
Upvotes: 1
Views: 328
Reputation: 465
to get all the tag use this function
get_tags()
for second question yes you can get all the posts by above mentioned code..
use $my_query in loop you will get the post.
Upvotes: 1