我有一个自定义的帖子类型:“视频”,我使用默认标签的视频帖子。现在,我想得到所有的视频帖子,有相同的标签。首先是获取所有的标记,下面是我的代码:
 $tags =wp_get_object_terms( $post->ID, 'post_tag'); 我也试过
$tags =the_terms( $post->ID, 'post_tag');这两种方法都行不通。它们返回空数组()。
我可以通过链接看到仪表板上的所有帖子:
videostags=ihealth&post_type=videos另一个问题是,我是否可以通过这样的标签id获得所有的帖子:
                $args=array(
                  'tag__in' => 4,
                  'post__not_in' => array($post->ID),
                  'showposts'=>5,
                  'ignore_sticky_posts'=>1
                );
               $my_query = new WP_Query($args);发布于 2014-08-23 08:34:21
要获取所有标记,请使用以下函数
get_tags()对于第二个问题,是的,您可以通过上面提到的代码获得所有的帖子。
在循环中使用$my_query,您将得到post。
https://stackoverflow.com/questions/25459987
复制相似问题