【问题标题】:How to find untagged posts on WordPress?如何在 WordPress 上找到未标记的帖子?
【发布时间】:2016-11-26 20:58:02
【问题描述】:

我有一些未标记的帖子,但我找不到可以列出所有未标记帖子的选项,因此我可以删除它们。

我读过一些关于此的文章,他们说我需要对 wp_query 做一些更改,但我不熟悉 php,我知道一些基本的编码知识但不知道 php,我希望有人解释我是如何做到的,这样我就可以列出我所有未标记的帖子

我找到了这段代码:

    $tag = get_the_tags();
if (! $tag) {
echo 'this post has no tags ' . /the_permalink();
}

我是在https://wordpress.org/support/topic/how-can-i-list-all-the-posts-that-have-0-tags?replies=5找到的,但问题是对php不熟悉,所以不知道上面的代码放在哪里,谁能帮忙??

【问题讨论】:

    标签: php sql wordpress find posts


    【解决方案1】:

    这不是获取没有标签的帖子的最佳方式。另请注意该链接中帖子的日期 - 7 年前!这绝对是明显过时的。

    看看这篇 WordPress StackExchange 帖子,它向您展示了如何使用 wp_querytax_query 选项检索无标签帖子:https://wordpress.stackexchange.com/questions/114978/get-all-posts-without-tags

    $tags = get_terms('post_tag', array('fields'=>'ids') );
    $args = array(
      'post_type' => 'post',
      'posts_per_page' => -1,
      'tax_query' => array(
        array(
          'taxonomy' => 'post_tag',
          'field' => 'id',
          'terms' => $tags,
          'operator' => 'NOT IN'
        )
      )
    );
    $untagged = new WP_Query( $args );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-28
      • 2010-12-16
      • 1970-01-01
      • 1970-01-01
      • 2011-07-12
      • 2013-06-21
      相关资源
      最近更新 更多