Im using a random query on a wordpress tube theme to insert a random number of post in index page before the regular post. For some reason, the query works fine on the home page, but if you surf to the second page, it doesnt work.
Code:
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('showposts=20&orderby=rand');
while (have_posts()) : the_post();
?>
post content
<?php endwhile; wp_reset_query()?>
this is a custom pagination function being used (*i didnt write this snippet came with the theme)
Code:
//Pagination function
function pagination($pages = '', $range = 6)
{
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '')
{
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages)
{
$pages = 1;
}
}
if(1 != $pages)
{
echo "<span>Page ".$paged." of ".$pages."</span> ";
if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a class=\"pFirst\" href='".get_pagenum_link(1)."'>First</a>";
// if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>‹ Previous</a>";
for ($i=1; $i <= $pages; $i++)
{
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
{
echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>";
}
}
// if ($paged < $pages && $showitems < $pages) echo "<a href=\"".get_pagenum_link($paged + 1)."\">Next ›</a>";
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a class=\"pLast\" href='".get_pagenum_link($pages)."'>Last</a>";
}
}
I dont see any reason for them to conflict, they work fine on the home page , looking for answers from someone better at wp than me
