如何更改此循环以显示当前标记中的帖子。现在它显示所有帖子。我需要这个来制作页面tag.php
<?php
$current_page = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'posts_per_page' => 7,
'paged' => $current_page
);
query_posts($args);
$wp_query->is_archive = true;
$wp_query->is_home = false;
while(have_posts()): the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="post_headline">
<h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
</div>
<?php
endwhile;
if (function_exists('custom_pagination')) {
custom_pagination($query->max_num_pages,"",$paged);
}
?>
答案 0 :(得分:1)
您好我们需要将标记名称传递给查询帖子参数列表,所以我只是修改了代码,请尝试下面的代码并告诉我是否有任何问题,
<?php
$current_page = (get_query_var('paged')) ? get_query_var('paged') : 1;
$tag = get_queried_object();
$args = array(
'posts_per_page' => 7,
'tag' => $tag->slug,
'paged' => $current_page
);
query_posts($args);
$wp_query->is_archive = true;
$wp_query->is_home = false;
while(have_posts()): the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="post_headline">
<h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
</div>
<?php
endwhile;
if (function_exists('custom_pagination')) {
custom_pagination($query->max_num_pages,"",$paged);
}
?>