在1页上加载所有内容

时间:2014-04-02 19:03:01

标签: wordpress wordpress-theming

我正在创建一个图库,所有图片都显示在1页本身上,但是只显示了最新上传的10张图片...我如何让所有这些图片显示在下面是我的代码

<?php get_header(); ?>          


<article>

            <?php while (have_posts()) : the_post(); ?> 

                        <div class="index">
                          <div class="thumb"><?php the_post_thumbnail('')?> </div>
                        </div>

            <?php endwhile; ?>
</article>

<?php get_sidebar(); ?>

<?php get_footer(); ?>

2 个答案:

答案 0 :(得分:1)

问题是你使用标准WordPress循环运行它。通常标准的WordPress循环限制为十个。您可以在“设置”中更改 - &gt;阅读 - &gt;博客页面最多显示

但是如果你不想改变它,你需要把它放在循环之前

wp_reset_query();
query_posts( 'posts_per_page=10000' ); // will proably show 10000 now as seen in the other answers -1 should show all

开头
<?php while (have_posts()) : the_post(); ?> 

http://codex.wordpress.org/Function_Reference/query_posts https://codex.wordpress.org/Function_Reference/wp_reset_query

到目前为止还不错?

答案 1 :(得分:0)

基本的WordPress设置只会调出最后的10个。您需要自己创建查询才能运行更多帖子。

试试这个:

<?php get_header(); ?>          


<article>

    <?php
        $query = new WP_Query( 'posts_per_page=-1' );
        while ($query->have_posts()) : $query->the_post(); 
    ?> 

        <div class="index">
            <div class="thumb"><?php the_post_thumbnail('')?> </div>
        </div>

    <?php endwhile; ?>
</article>

<?php get_sidebar(); ?>

<?php get_footer(); ?>

完整的解释可以在codex中找到。

有关上述用法的详细信息,请参阅HERE