简体   繁体   English

WordPress自定义字段仅显示10个帖子

[英]Wordpress custom field only displaying 10 posts

I've used wordpress Advanced Custom Fields plugin to make my portfolio page. 我使用了wordpress 高级自定义字段插件来制作我的投资组合页面。 I've setup fields for the image, title, category and a yes/no for weather the project is featured. 我已经为图像,标题,类别设置了字段,并为项目具有特色的天气设置了是/否。

My code for the project page is as follows: 我在项目页面上的代码如下:

<?php

    $args = array(
        'post_type' => 'project'
    );

    $query = new WP_Query( $args );

?>

<?php Starkers_Utilities::get_template_parts( array( 'parts/shared/html-header', 'parts/shared/header' ) ); ?>

<h1 class="lead"><?php the_title(); ?></h1>

<div id="triggers">
    <strong>Filter:</strong>
    <span id="filterDouble">Filter All</span>   
    <span id="filter1">Filter 1</span>
    <span id="filter2">Filter 2</span>
</div>

<ul id="gallery" class="group">
    <?php if ( have_posts() ) while ( $query->have_posts() ) : $query->the_post(); ?>

        <li class="gallery_image" data-id="id-" data-type="<?php the_field('project_category')?>">

                <a rel="prettyPhoto[gallery]" class="zoom" href="<?php echo the_field('image') ?>">

                    <img class="mag" src="<?php bloginfo('template_url'); ?>/imgs/mag.png"/><div class="thumb_bg"></div>
                    <?php the_post_thumbnail('portfolio'); ?>
                </a>                                    


        </li>
    <?php endwhile; ?>
</ul>

Everything works fine, i can add projects. 一切正常,我可以添加项目。 However My problem starts when i hit 10 projects. 但是当我打10个项目时, 我的问题就开始了 After 10, it doesn't display anymore. 10点之后,它将不再显示。 I am using jpages (jquery plugin) and filtrify to add filters to filer out the categories. 我正在使用jpages(jquery插件)和filtrify添加过滤器以过滤类别。 They work fine, i can filter by category and i see the correct images. 他们工作正常,我可以按类别过滤,我可以看到正确的图像。 Even with the plugin scripts removed, i still only see a max of 10 posts. 即使删除了插件脚本,我最多只能看到10个帖子。 Adding more than 10 simply pushes the earlier images off and it displays the 10 latest. 添加10个以上只会推开较早的图像,并显示10张最新的图像。

So how can i stop it from being just 10.. My jpage script sets the pagination to 12 per page, but this doesn't even get a chance to kick in. I am thinking it's a post problem as I'm certain it's not the scripts. 因此,如何才能将其从10开始制止。我的jpage脚本将分页设置为每页12个,但这甚至没有机会插入。我认为这是一个后期问题,因为我确定不是脚本。

I think I've traced an issue - I tested this: 'posts_per_page' => '20' - Which DOES display my missing posts, however i don't want to set a number as i might need lots. 我认为我已经跟踪了一个问题 -我对此进行了测试: 'posts_per_page' => '20'哪些显示我丢失的帖子,但是我不想设置数字,因为我可能需要很多。 How can i define an unlimited number. 我如何定义无限数量。 Providing this is the issue.. 提供这个是问题。

If any other code is needed, please let me know, but i think this is the main part of what's controlling my posts appearing on the page. 如果需要任何其他代码,请告诉我,但是我认为这是控制页面上显示我的帖子的主要部分。

You're on the right track.Set the value to -1 to get your desired results. 您在正确的轨道上,将该值设置为-1可得到所需的结果。

Link to the documentation: http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters 链接到文档: http : //codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters

posts_per_page (int) - number of post to show per page (available with Version 2.1, replaced showposts parameter). posts_per_page(int)-每页显示的帖子数(在2.1版中可用,已替换showposts参数)。 Use 'posts_per_page'=>-1 to show all posts . 使用'posts_per_page'=>-1显示所有帖子 Set the 'paged' parameter if pagination is off after using this parameter. 如果使用此参数后分页功能已关闭,则设置“分页”参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM