【问题标题】:How can I make a Wordpress query which only uses some of the tags associated with the post and not all the tags?如何进行仅使用与帖子相关联的一些标签而不是所有标签的 Wordpress 查询?
【发布时间】:2014-06-04 12:24:12
【问题描述】:

我正在尝试使用标签在我的网站上显示相关内容。 我的帖子有多个链接到类似内容的标签。

在帖子上运行查询时,我想忽略某些标签。 这可能吗?

例如

Post-A 有 3 个标签,Tag-1、Tag-2 和 Tag-3

Post-B 有 5 个标签,Tag-1、Tag-2、Tag-4、Tag-5 和 Tag-6

对于我的查询,我要求始终忽略 Tag-1 和 Tag-2。

我的理想结果是;

Post-A 显示 Tag-3,Post-B 显示 Tag-4、Tag-5 和 Tag-6

【问题讨论】:

    标签: tags wordpress


    【解决方案1】:
    use this wp query . I hope it will work for you. 
    
    $the_query = new WP_Query( array( 'tag__not_in' => array( 10 ) ) );
    
    while ( $the_query->have_posts() ) : $the_query->the_post();
    
    endwhile;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-09
      • 2013-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多