Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Blogging Forum


You are currently viewing our Blogging Forum as a guest. Please register to participate.
Login



Reply
Wordpress pagination problem: Adding extra page with no posts in there
Old 10-25-2010, 06:43 AM Wordpress pagination problem: Adding extra page with no posts in there
pealo86's Avatar
Super Spam Talker

Posts: 876
Name: Matt Pealing
Location: England, north west
Trades: 0
I have set up a form on the following page that sends the values of all of its fields to a template page that creates a loop out of the values using $_GET variables. Click the link below to see the results of a search (to save you having to fill the form in):
http://bit.ly/buRKvQ

At first, I couldn't get the pagination to work properly, clicking 'next' simply displayed no results, as if the loop did not pull any posts in.

Suddenly I seem to have got it working (not sure what I did differently to the last time I attempted to fix it, but oh well). However there should only be two pages of results, with a maximum of two posts on each but WordPress adds a third page of results.

There should only be 3 posts; 2 posts on one page, 1 post on the second. This is how it should be, however the 3rd (and unnecessary) page displays no posts, so I cant understand why WP is adding it??

I have tried echoing the $paged variable and it gives me some very strange results (see on the page), they seem to be numbered '0, 2, 3'.

Shouldn't it be '0, 1, 2' or '1, 2, 3'?? I assume the problem is somehow related to the $paged variable.

If anybody has any advice that would be great
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
 
Register now for full access!
Old 10-25-2010, 11:21 AM Re: Wordpress pagination problem: Adding extra page with no posts in there
racer x's Avatar
Ultra Talker

Posts: 457
Name: Randy
Location: Northern Wisconsin
Trades: 0
What is your full wp_query() ?

I think WP still returns the "total" number of posts in that category regardless of how many are supposed to get displayed based on a custom wp_query.

I stumbled on this issue myself when trying to incorporate a slider that was set up to display 2 posts per slide in the past.
racer x is offline
Reply With Quote
View Public Profile Visit racer x's homepage!
 
Old 10-25-2010, 04:16 PM Re: Wordpress pagination problem: Adding extra page with no posts in there
pealo86's Avatar
Super Spam Talker

Posts: 876
Name: Matt Pealing
Location: England, north west
Trades: 0
Ahhh I see! Here is the full loop if that helps:
PHP Code:
    <?php if (have_posts()) : ?>
    <?php $count 0?>

    <?php while (have_posts()) : the_post(); ?>
    <?php $count++; ?>

    <?php if ($count <= 1) : ?>

    <div class="post">
        <h2 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

      <div class="entryLatest">
    <?php the_content(); ?>
        <?php if($_GET['searchTitle']) : ?>
            <h1><?php echo $paged?></h1>
            <?php query_posts('post_type=job&meta_key=JobType&meta_value=' $_POST['searchJobType'] . '&posts_per_page=2&paged=' $paged); ?>
                <?php if(have_posts()) : ?>
                    <?php while(have_posts()) : the_post(); ?>
                        <?php if((get_the_title() == $_GET['searchTitle']) && (get_meta('JobType') == $_GET['searchJobType']) && (get_meta('WorkingHours') == $_GET['searchWorkingHours'])) : ?>
                            <?php 
                                
// get distance
                                
$location explode(' '$_GET['searchLocation']);
                                
$postcode explode(' 'get_meta('Location'));
                                
$location $location[0];
                                
$postcode $postcode[0];
                                
$distance calc_postcode_seperation($location$postcode);
                                
                                
// filter distances
                                
switch($_GET['searchMile']) {
                                    
// up to 5
                                    
case 0:
                                        if (
$distance <= 5) : ?>
                                            <strong><?php the_title(); ?></strong>
                                            <?php the_excerpt(); ?>
                                        <?php endif;
                                    break;
                                    
                                    
// 5 - 10
                                    
case 1:
                                        if (
$distance && $distance <= 10) : ?>
                                            <strong><?php the_title(); ?></strong>
                                            <?php the_excerpt(); ?>
                                        <?php endif;
                                    break;
                                    
                                    
// 10 - 20
                                    
case 2:
                                        if (
$distance 10 && $distance <= 20) : ?>
                                            <strong><?php the_title(); ?></strong>
                                            <?php the_excerpt(); ?>
                                        <?php endif;
                                    break;
                                    
                                    
// 20+
                                    
case 3:
                                        if (
$distance 20) : ?>
                                            <strong><?php the_title(); ?></strong>
                                            <?php the_excerpt(); ?>
                                        <?php endif;
                                    break;
                                }
                            
?>
                        <?php endif; ?>
                    <?php endwhile; ?>
                    <?php posts_nav_link(); ?>
                <?php endif; ?>
            <?php wp_reset_query(); ?>
        <?php endif; ?>
    </div><!-- end #content -->
    
    <p class="meta"><span style="font-weight: bold"><img src="./images/calendar.png" width="16" height="16" align="absmiddle" /></span> <?php the_time('F jS, Y'?> under <?php the_category(', '?>&nbsp;<?php the_tags('<img src="images/tag.png" width="16" height="16" />'', '''); ?>&nbsp;&bull;&nbsp;<?php edit_post_link('Edit''''&nbsp;&bull;&nbsp;'); ?><?php comments_popup_link('No Comments''1 Comment''% Comments'); ?></p>
    </div>
    
    <?php else : ?>
    
    <div class="post">
    <h2 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    
    <div class="entry">
    <?php the_content(); ?>
    </div><!-- end #content -->
    
    <p class="meta"><span style="font-weight: bold"><img src="./images/calendar.png" alt="" width="16" height="16" align="absmiddle" /></span> <?php the_time('F jS, Y'?> under <?php the_category(', '?>&nbsp;<?php the_tags('<img src="images/tag.png" width="16" height="16" />'', '''); ?>
      &nbsp;&bull;&nbsp;<?php edit_post_link('Edit''''&nbsp;&bull;&nbsp;'); ?><?php comments_popup_link('No Comments''1 Comment''% Comments'); ?></p>
    
    </div>

    <?php endif; ?>
    <?php endwhile; ?>
    <?php else : ?>
    <?php endif; ?>
Thanks
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Reply     « Reply to Wordpress pagination problem: Adding extra page with no posts in there
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12619 seconds with 12 queries