小编Ty *_* T.的帖子

wp-query 类别并有标签

我正在尝试使用 wp_query 查询 wordpress 中的帖子。我想使用 has_tag 将帖子放在一个类别中并进行查询。我试着用

$args = array (
                    'post_type'  => array( 'post' ),
                    'category_name' => 'footer',
                );
                // The Query
                $social = new WP_Query( $args );
                // The Loop
                if ( $social->have_posts()&&has_tag('social') ) {
                    while ( $social->have_posts() ) {
                        $social->the_post();
                        the_content();
                    }
                } rewind_posts();
                ?>
Run Code Online (Sandbox Code Playgroud)

但这会加载所有帖子,而不仅仅是显示带有标签的帖子。

php wordpress

2
推荐指数
1
解决办法
970
查看次数

标签 统计

php ×1

wordpress ×1