Support

Account

Home Forums Front-end Issues Weird array

Solving

Weird array

  • Hello there,

    I’m trying to display a list of logos with the following code.

    The odd thing is that the list gets cut off after the fourth entry, so that only the newer items are displayed.

    <?php $clients = new WP_Query(array(
    	'post_type' => 'clients'
    ));?>
    
    <?php while($clients->have_posts()) : $clients->the_post();?>
    			
    <?php 
    			
    	$image = get_field('logo');
    
    		if( !empty($image) ): ?>
    				
    			a href="<?php the_field('url'); ?>"><img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /></a>
    				
    		<?php endif; ?>
    <?php endwhile; ?>

    Any idea why this might be happening?

    Cheers,

    Spen

  • Try

    <?php $clients = new WP_Query(array(
    	'post_type' => 'clients',
    	'posts_per_page' => -1,
    ));?>
  • Hi @spen


    @brugman
    solution should be able to solve the issue since having posts_per_page set to -1 allows us to display an unlimited number of results. You could also add a ‘&’ and then another parameter after “posts_per_page=-1″ to further alter the query.

    The following could also work :

    $args = array(
        'posts_per_page' => a'-1',
        );
    query_posts( $args );
Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Weird array’ is closed to new replies.