S

Continued WordPress Post Numbering

13th June, 2009

My further experimentation led me to requiring the current number of a post which there is surprisingly little information about, so I ended up working something out from scratch.

I’ve posted it on the wordpress forum in case it proves useful for anyone else: http://wordpress.org/support/topic/245629

Update: Since this is now closed, I have included the code I made originally here:


function Get_Post_Number($postID){
$temp_query = $wp_query;
$postNumberQuery = new WP_Query('orderby=date&posts_per_page=-1');
$counter = 1;
$postCount = 0;
if($postNumberQuery->have_posts()) :
while ($postNumberQuery->have_posts()) : $postNumberQuery->the_post();
if ($postID == get_the_ID()){
$postCount = $counter;
} else {
$counter++;
}
endwhile; endif;
wp_reset_query();
$wp_query = $temp_query;
return $postCount;
}

Posted in Web Design by Simon

WordPress Post Numbering

12th June, 2009

A plugin that will produce similar links to those found at the bottom of a google or flickr results page.

http://wordpress.org/extend/plugins/wp-page-numbers/

Unfortunately this wasn’t quite what I was after, since it works with the existing pagination system of WordPress.

Tags: , ,
Posted in Web Design by Simon

Latest Journal Posts

RSS Feed

Additional