Skip to main content
extended with example code
Source Link
Michael
  • 8.4k
  • 3
  • 30
  • 31

for a standard query, you can check the amount of posts with:

all posts for the query: $wp_query->found_posts

and the posts on the page: $wp_query->post_count

use that with a conditional statement to switch to the different layouts.

example:

<?php if ( have_posts() ) : //start of the loop// if ( $wp_query->found_posts <= 4 ) { ?> list output of posts //this will need to include the 'while(have_posts())' including the 'endwhile' of the loop <?php } else { ?> float block output //this will need to include the 'while(have_posts())' including the 'endwhile' of the loop <?php } endif; ?> 

for a standard query, you can check the amount of posts with:

all posts for the query: $wp_query->found_posts

and the posts on the page: $wp_query->post_count

use that with a conditional statement to switch to the different layouts.

for a standard query, you can check the amount of posts with:

all posts for the query: $wp_query->found_posts

and the posts on the page: $wp_query->post_count

use that with a conditional statement to switch to the different layouts.

example:

<?php if ( have_posts() ) : //start of the loop// if ( $wp_query->found_posts <= 4 ) { ?> list output of posts //this will need to include the 'while(have_posts())' including the 'endwhile' of the loop <?php } else { ?> float block output //this will need to include the 'while(have_posts())' including the 'endwhile' of the loop <?php } endif; ?> 
Source Link
Michael
  • 8.4k
  • 3
  • 30
  • 31

for a standard query, you can check the amount of posts with:

all posts for the query: $wp_query->found_posts

and the posts on the page: $wp_query->post_count

use that with a conditional statement to switch to the different layouts.