I'm using the "bones" theme on WordPress. On my blog page I'm trying to have it with 9 blog posts displayed in 3 columns, but on the first page have 10 blog posts with the first (most recent) one being enlarged to span all 3 columns.
What is the best way to display 10 posts on the first page and 9 thereafter without messing up the pagination?
Here's my code: (I removed all the HTML and what-not because I assume it's not needed)
<?php if (have_posts()) : ?>
<?php $post = $posts[0]; $c=0;?>
<?php while (have_posts()) : the_post(); ?>
<?php $c++;
if( !$paged && $c == 1){
//code for the first post
} else { // THE REST: begin the code for the remainder of the posts ?>
<?php }
endif; ?>
<?php endwhile; ?>
I haven't really experimented with it as I don't have the page function set up - but try this
<?php
$post = $posts[0]; $c=0;
$c++; if( !$paged && $c == 1){
$query1 = new WP_Query( array ('posts_per_page' => 1 ) );
if ($query1-> have_posts()) : while ($query1-> have_posts()) : $query1-> the_post(); ?>
<?php the_title(); ?>
<?php endwhile; endif; wp_reset_query();}
else{
$query2 = new WP_Query( array ('posts_per_page' => 9, 'offset' => 1 ) );
if ($query2-> have_posts()) : while ($query2-> have_posts()) : $query2-> the_post(); ?>
<?php the_title(); ?>
<?php endwhile; endif; wp_reset_query(); }?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.