最近的博客文章限制了主页上的限制



我遇到一些问题,设置了在主页上显示的帖子数量。当我设置要在主题选项中显示的帖子数时,它将恢复到3。我想将帖子数从3更改为5。

这是我的home.php上的代码块,我认为需要进行一些完善。

->
            <?php $recent = new WP_Query("cat=".get_theme_mod('featured_top_left')."&showposts=".get_theme_mod('featured_top_left_num')); while($recent->have_posts()) : $recent->the_post();?>
            <?php if( get_post_meta($post->ID, "thumb", true) ): ?>
            <a href="<?php the_permalink() ?>" rel="bookmark"><img class="thumb" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", $single = true); ?>&amp;h=<?php echo get_theme_mod('featured_top_left_thumb_height'); ?>&amp;w=<?php echo get_theme_mod('featured_top_left_thumb_width'); ?>&amp;zc=1" alt="<?php the_title(); ?>" /></a>    
            <?php else: ?>
            <?php endif; ?> 

根据WordPress手册:

showposts(int) - 每页显示的帖子数。弃用 2.1版支持" Posts_per_page"。

因此,如果您是版本> 2.1,则应编辑代码,并用WP_Query中的showposts替换CC_3。

        <?php $recent = new WP_Query("cat=".get_theme_mod('featured_top_left')."&posts_per_page=".get_theme_mod('featured_top_left_num'));

更新的代码。

最新更新