• Resolved 000000000

    (@pealo86)


    I have a page on my website 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’

    /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

    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??

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter 000000000

    (@pealo86)

    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
    /**
     * @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(); ?>
    Thread Starter 000000000

    (@pealo86)

    Fixed it! Just had to add

    paged=' . $paged

    to the end of my query_posts() parameters

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Passing $_GET variable makes pagination malfunction’ is closed to new replies.