Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 06-21-2013, 06:39 AM   #1
tonyparra
Confirmed User
 
tonyparra's Avatar
 
Industry Role:
Join Date: Jul 2008
Location: In your back seat with duck tape
Posts: 4,568
Weird Wordpress Random Query Issue

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>&nbsp;&nbsp;";
         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)."'>&lsaquo; 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 &rsaquo;</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
__________________

High Performance Vps $10 Linode
Manage your Digital Ocean, Linode, or Favorite Cloud Server. Simple, fast, and secure Server Pilot
tonyparra is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-21-2013, 07:42 AM   #2
tonyparra
Confirmed User
 
tonyparra's Avatar
 
Industry Role:
Join Date: Jul 2008
Location: In your back seat with duck tape
Posts: 4,568
bump for wp pros
__________________

High Performance Vps $10 Linode
Manage your Digital Ocean, Linode, or Favorite Cloud Server. Simple, fast, and secure Server Pilot
tonyparra is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.