Frage

My client has a custom post type called 'Clients'. She uses this to record all information about each client she has. She then sometimes leaves these in either draft mode or published. She would like to be able to see all of her clients at a glance and copy and paste all of their details straight from the web page on a regular basis. I have created the following query (note the query is only showing fist and last name at the moment for testing):

        <?php
        $args = array( 
            'post_type' => 'clients',
            'post_status' => array('draft', 'publish'),
            'orderby' => 'menu_order',
            'order' => 'ASC',
            'posts_per_page' => -1
            );
            $loop = new WP_Query( $args );
            while ( $loop->have_posts() ) : $loop->the_post();
                $fname = get_field('fname');
                $sname = get_field('sname');

                echo '<p>'.$fname.', '.$sname.'</p>';
            endwhile;
        ?>

However, this returns no results. When I change the 'posts_per_page' to a number, the query works. However, if this number is above 58 no results are returned again. I think somewhere there is a limit to how much can be output in 1 query. I cannot use pagination at the minute as the client is admit she'd want to see all information on one page. Is there another way of querying this without limits? Or a way to adjust the limit?

Thank you in advance

War es hilfreich?

Lösung 3

The problem was down to my local setup, as soon as it was uploaded to the clients server the error disappeared. Sorry I forgot to close the question

Andere Tipps

Without being able to debug it directly I'm not sure why you're seeing this issue. Alternatively you can try using the 'nopaging' => true option instead of the 'posts_per_page' option. Does that method behave?

Are you sure that the custom post type name is clients and not client? That is the only thing that I can point, as I the only parameter that is custom by the developer ^^.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top