如何在WordPress中手动限制帖子数量?
下面是我试图修改以限制帖子数量的代码如何在WordPress中手动限制帖子数量?,wordpress,wordpress-theming,Wordpress,Wordpress Theming,下面是我试图修改以限制帖子数量的代码 $loopcount = 0; $additional_loop = new WP_Query("paged=$paged&cat=".$k_option['gallery']['gallery_cat_final']."&posts_per_page=".$k_option['gallery']['post_count']); 文章的数量似乎是从每页$posts\u获得的,默认的文章数量是在WordPress中设置的 如何手动更改
$loopcount = 0;
$additional_loop = new WP_Query("paged=$paged&cat=".$k_option['gallery']['gallery_cat_final']."&posts_per_page=".$k_option['gallery']['post_count']);
文章的数量似乎是从每页$posts\u获得的,默认的文章数量是在WordPress中设置的
如何手动更改它
我试着这样做:
"&posts_per_page="6);
这行不通
我不擅长PHP,所以请大家帮帮我
提前多谢 这篇文章可以帮助-
有两种方法,一种是取一个变量,循环它直到你想要的极限,然后不断递增它
下面是同样的代码片段
<?php $i = 1; while (have_posts() && $i < 6) : the_post(); ?>
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<p>?php the_time(); ?></p>
<?php the_content(); ?>
<p><?php the_tags(); ?></p>
<?php $i++; endwhile; ?>
<p><?php next_posts_link(); ?></p>
<p><?php previous_posts_link(); ?></p>
<?php else : ?>
<h1>Not Found</h1>
<p>Silly monkey.</p>
<?php endif; ?>
?php_time();?>
找不到
傻猴子
希望这对ypu有帮助:)
?>
<?php
$args = array(
'post_type' => 'post',
'posts_per_page' => 12,
'paged' => $page,
);
query_posts($args);?>
?>