Skip to content

Instantly share code, notes, and snippets.

@pippinsplugins
Forked from jarretc/gist:3548761
Created August 31, 2012 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pippinsplugins/3553850 to your computer and use it in GitHub Desktop.
Save pippinsplugins/3553850 to your computer and use it in GitHub Desktop.
function jc_paged_posts_columns() {
echo '<div id="paged-columns">';
global $post;
$numposts = 11;
$args = array( 'numberposts' => $numposts, 'offset' => 10 );
$column1 = get_posts( $args );
echo '<ul class="column-list">';
echo '<li class="column-heading">Page 2</li><ol>';
foreach ( $column1 as $post ) : setup_postdata($post); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; wp_reset_postdata();
echo '</ol></ul>';
$args = array( 'numberposts' => $numposts, 'offset' => 21 );
$column2 = get_posts( $args );
echo '<ul class="column-list">';
echo '<li class="column-heading">Page 3</li><ol>';
foreach ( $column2 as $post ) : setup_postdata($post); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; wp_reset_postdata();
echo '</ol></ul>';
$args = array( 'numberposts' => $numposts, 'offset' => 32 );
$column3 = get_posts( $args );
echo '<ul class="column-list">';
echo '<li class="column-heading">Page 4</li><ol>';
foreach ( $column3 as $post ) : setup_postdata($post); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; wp_reset_postdata();
echo '</ol></ul>';
echo '</div>';
}
@pippinsplugins
Copy link
Author

Take a look at my forked version. You are missing wp_reset_postdata().

It's going to have problems when you change $numposts to something else. I would suggest that you auto calculate the offset based what $numposts is set to. You could actually set this up in a while() or for() loop pretty easily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment