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: Passing $_GET variable makes pagination malfunction
Old 08-05-2010, 08:30 AM Wordpress: Passing $_GET variable makes pagination malfunction
pealo86's Avatar
Super Spam Talker

Posts: 876
Name: Matt Pealing
Location: England, north west
Trades: 0
I have a page on a Wordpress theme that I'm building that pulls in excerpts of custom posts, 10 per page.
Which posts it pulls in depends on what value is contained within the 'county' $_GET variable. For example, this page will pull in posts from the county 'Cheshire'

Code:
/directory/?county=Cheshire
The pagination nav appears correctly as there are more than 10 entries. However if I click 'next' I am taken to a new page


Code:
directory/page/2/?county=Cheshire
But this page displays the same entries that were on page 1! It does not display any posts after the 10th entry.


Then when I click 'previous' I am taken back to the first page (with the same results showing again).


Does anybody know what might be wrong? Is it not recommended passing $_GET variables in WordPress??
__________________

Please login or register to view this content. Registration is FREE

Last edited by pealo86; 08-05-2010 at 11:50 AM..
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
 
Register now for full access!
Old 08-05-2010, 11:30 AM Re: Wordpress: Passing $_GET variable makes pagination malfunction
pealo86's Avatar
Super Spam Talker

Posts: 876
Name: Matt Pealing
Location: England, north west
Trades: 0
Quick update, the error can't be caused by the $_GET variable, if I remove it and add the county name as a parameter in query_posts() then I still have the same problem!

Here is the code I'm using:
PHP Code:
<?php
/**
 * @package WordPress
 * Template Name: Directory
 */
?>

<?php get_header(); ?>
<div id="page">
    <div id="content">
        <?php get_search_form(); ?>
        <?php // if($_GET['county']) : ?>
            <h1>Companies in <?php echo $_GET['county']; ?></h1>
            <?php query_posts('post_type=company&meta_key=County&meta_value=Cheshire&orderby=title&order=ASC'); ?>
            <div id="directory-result">
                <?php if(have_posts()) : ?>
                    <?php while(have_posts()) : the_post(); ?>
                        <div class="divide">
                            <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                            <?php the_excerpt(); ?>
                            <ul class="contact">
                                <li><?php echo_meta('Town / City'); ?></li>
                                <li><?php echo_meta('Telephone'); ?></li>
                                <li><a href="mailto:<?php echo_meta('Email'); ?>"><?php echo_meta('Email'); ?></a></li>
                                <li class="last"><a href="<?php echo_meta('Website'); ?>"><?php echo_meta('Website'); ?></a></li>
                            </ul>
                        </div>
                    <?php endwhile;    ?>
                    <div id="paginate">
                        <a id="link-top" href="#top"><img src="<?php bloginfo('template_url'); ?>/image/paginate-top.gif" alt="Back to Top" /></a>
                        <ul>
                            <?php posts_nav_link(' ''<li><img src="' get_bloginfo('template_url') . '/image/paginate-prev.gif" alt="Previous Page" /></li>''<li><img src="' get_bloginfo('template_url') . '/image/paginate-next.gif" alt="Next Page" /></li>'); ?>
                        </ul>
                    </div>
                    <?php else : ?>
                        <p>There are currently no companies registered in <?php echo $_GET['county']; ?>. If you own a business in this location then <a href="<?php bloginfo('url'); ?>/wp-admin">submit to our business directory for free</a> today!</p>
                <?php endif; ?>
            </div>
            <?php wp_reset_query(); ?>
        <?php // endif; ?>
    </div><!--end content-->
    <?php get_sidebar(); ?>
</div><!--end page-->
<?php get_footer(); ?>
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Old 08-05-2010, 12:18 PM Re: Wordpress: Passing $_GET variable makes pagination malfunction
pealo86's Avatar
Super Spam Talker

Posts: 876
Name: Matt Pealing
Location: England, north west
Trades: 0
Fixed it! Just had to add

Code:
 paged=' . $paged
to the end of my query_posts() parameters
__________________

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: Passing $_GET variable makes pagination malfunction
 

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.11648 seconds with 12 queries