0

我希望能够为 Jetpack 特色内容模块调用用户选择的标签 ID,但我找不到包含该值的函数或对象。

我基本上是在尝试使用以下参数从 WP_Query 中过滤精选帖子:

$args = array(
        'ignore_sticky_posts' => 1,                 
        'posts_per_page' => $recent_posts_count,
        'tag__not_in'   => array(
            [HERE IS WHERE I WANT PHP TO TELL ME THE TAG ID]
        ),
        'post_type' => array(               
            'post'                  
        )
    );  
4

2 回答 2

0

我知道这已经很晚了,但我在寻找同样的东西时发现了这篇文章,甚至发布在 WordPress 支持论坛上,但最终还是想通了:

$featured_options = get_option( 'featured-content' );
$featured_name = $featured_options[ 'tag-name' ];
于 2015-04-03T21:02:49.980 回答
0

检查这个

<?php

        global $post;
        $tags = get_tags($post->ID);
        $tagids = array();
        foreach($tags as $tag) $tagids[] = $tag->term_id;
    $args = array(
            'ignore_sticky_posts' => 1,                 
            'posts_per_page' => $recent_posts_count,
            'tag__not_in'   => $tagids,
            'post_type' => array(               
                'post'                  
            )
        );  
    ?>

谢谢

于 2014-04-04T15:21:06.873 回答