【问题标题】:Wordpress Jetpack Featured Content Tag IDWordpress Jetpack 特色内容标签 ID
【发布时间】:2014-04-04 14:44:31
【问题描述】:

我希望能够为 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'                  
        )
    );  

【问题讨论】:

    标签: php wordpress jetpack


    【解决方案1】:

    检查这个

    <?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'                  
                )
            );  
        ?>
    

    谢谢

    【讨论】:

    • 这在哪里访问 Jetpack 以找出特色标签 ID?
    【解决方案2】:

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

    $featured_options = get_option( 'featured-content' );
    $featured_name = $featured_options[ 'tag-name' ];
    

    【讨论】:

      猜你喜欢
      • 2016-06-22
      • 2020-02-10
      • 1970-01-01
      • 1970-01-01
      • 2015-07-17
      • 1970-01-01
      • 2012-02-15
      • 2016-01-19
      • 1970-01-01
      相关资源
      最近更新 更多