WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Help! Pagination issue with Categorization (4 posts)

  1. squeaker2
    Member
    Posted 3 years ago #

    I hope I don't seem too stupid, maybe I am going about this all wrong. I am only 1/2 way through my Associates Degree so this stuff is pretty advanced for me. My pagination works perfect if I don't run a category first, but once sorted by category no such luck. Here are the snippets of code I think you will need. Any help is greatly appreciated!

    <?php if (isset($_GET['searchCat'])){
    			$myCAT = $_GET['searchCat'];
    			$hideheader = 'true';
    			query_posts('category_name='.$myCAT.''.'&posts_per_page='.$limitPagePosts.'');
    			}
    			else { query_posts($query_string.'&posts_per_page='.$limitPagePosts.'');}
    		?>
    		<?php $count = 0; $postid = 0;?>
    		<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
    
    LOOP CODE
    
    <?php endwhile; ?>
    
    		<?php endif; ?>
    
    <div class="rightnav">
    	<div class="sortbycat">
        	SORT BY CATEGORY:
        </div>
    
        <div class="categories">
        	<a href="?searchCat=commercial-photography">Commercial Photography</a><br />
            <a href="?searchCat=event-photography">Events & Occassions</a><br />
            <a href="?searchCat=people-personas">People & Personas</a><br />
            <a href="?searchCat=adventures-travel">Adventures & Travel</a><br />
            <a href="?searchCat=senior-portraits">Senior Portraits</a><br />
            <a href="?searchCat=creative-artistic">Creative & Artistic Photos</a><br />
            <a href="?searchCat=wedding-photography">Wedding Photography</a><br />
            <a href="?searchCat=retouching-photo">Retouching / Photo Editing</a><br />
            <a href="?searchCat=links-tools">Links & Tools</a><br />
            <a href="?searchCat=training-tutorials">Training & Tutorials</a><br />
            <a href="?searchCat=featured-work">Our Work Featured</a><br />
            <a href="?searchCat=behind-scenes">Behind the Scenes</a><br />
        </div>
    
    </div>

    I believe I can pass the variables through the URL right? The initial query works PERFECT. It realizes how many posts/pages it needs to account for, but the actual link wont link to the next posts. After I click... pagination adds &paged=2 to the url. So, after clicking I end up with index.php?searchCat=event-photography&paged=2 but it still displays page1. I found some fixes online, but I could not implement them properly apparently. :(

  2. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    Try:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('category_name='.$myCAT.''.'&posts_per_page='.$limitPagePosts.'&paged=' . $paged);
  3. squeaker2
    Member
    Posted 3 years ago #

    Thank you SO much.. omg i was getting frustrated, I really really appreciate your response!

  4. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    You're very welcome. :-)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.