我正在尝试使用 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)
但这会加载所有帖子,而不仅仅是显示带有标签的帖子。