GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Weird Wordpress Random Query Issue (https://gfy.com/showthread.php?t=1113176)

tonyparra 06-21-2013 06:39 AM

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 :helpme

tonyparra 06-21-2013 07:42 AM

bump for wp pros


All times are GMT -7. The time now is 10:06 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123