在TAX_QUERY中,代码正确吗?我需要访问不同主题的初学者视频帖子

时间:2017-06-21 作者:Adolfo Augusto Rodrigues
$args = array(
        \'post_type\'         => \'videolesson\',
        \'ordeby\'            => \'rand\',
        \'order\'             => \'DESC\',
        \'posts_per_page\'    => 8,
            \'tax_query\' => array(
                array(
                    \'taxonomy\' => \'level\',
                    \'field\' => \'slug\',
                    \'terms\' => \'beginner\',
                    \'operator\' => \'IN\',
                    array(
                        \'taxonomy\' => \'vidsubjects\',
                        \'operator\' => \'EXISTS\'
                    ),
                ),
            ),
    );
    $getting = new WP_Query( $args );
1 个回复
SO网友:Bikash Waiba

try this..

$args = array(
            \'post_type\'         => \'videolesson\',
            \'ordeby\'            => \'rand\',
            \'order\'             => \'DESC\',
            \'posts_per_page\'    => 8,
                \'tax_query\' => array(
                    \'relation\' => \'AND\',
                    array(
                        \'taxonomy\' => \'level\',
                        \'field\' => \'slug\',
                        \'terms\' => \'beginner\',
                        \'compare\' => \'IN\',

                    ),
                    array(
                       \'taxonomy\' => \'subjects\',
                       \'operator\' => \'EXISTS\'
                    )

                ),
        );
        $getting = new WP_Query( $args );
结束

相关推荐

使用新的WP-Query()从循环中过滤后期格式;

嗨,我目前正在为我的博客构建一个主题。下面的代码指向最新的帖子(特色帖子)。因为这将有一个不同的风格比所有其他职位。然而我想过滤掉帖子格式:链接使用我在循环中定义的WP查询,因为它给我带来了更多的灵活性。我该怎么做呢? <?php $featured = new WP_Query(); $featured->query(\'showposts=1\'); ?> <?php while ($featured->have_post