Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9068413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:11:08+00:00 2026-06-16T17:11:08+00:00

This may be an easy but I cannot get it figured out. I have

  • 0

This may be an easy but I cannot get it figured out. I have searched for hours with no luck on my situation. I need to get pagination to work with my_query

    <?php   
    $count = 0;
    $id_suffix = 1;
    $items_per_row = 4;
    $quality = 90;      
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;             
    $wp_query = new WP_Query( array( 'posts_per_page' => '4', 'post_type' => 'portfolio') );
    $grid_class = 'grid_3';
    $desired_width = 220;
    $desired_height = 190;
    $terms = get_terms( 'portfolio_categories' ); 
    $count_terms = count( $terms ); 
?>

//some php code 

<?php while ( $wp_query -> have_posts()) : $wp_query -> the_post(); //query the "portfolio" custom post type for portfolio items ?>


//some more php code 


<?php endwhile;?>
<div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">&laquo;</span> Older posts', 'thematic')) ?></div>
<div class="nav-next"><?php previous_posts_link(__('Newer posts <span class="meta-nav">&raquo;</span>', 'thematic')) ?></div>
</ul>

I got the pagination to display but when clicking on another page it shows the same portfolio items. Any help would be appreciated.

I got the pagination to show using wp-pagenavi but the same issue with not changing the items.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:11:09+00:00Added an answer on June 16, 2026 at 5:11 pm

    Thank you @maiorano84 and @s_ha_dum for pointing me in the right direction. I wanted to update this post for anybody that runs into the problem. The problem I was having was making the pagination work on the a static front page. After reading in the codex I figured out my problem.

    Instead of $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    I had to use
    $paged = (get_query_var('page')) ? get_query_var('page') : 1;

    That one little mistake is what kept the pagination to work. so the final code looked like this.

    <?php   
        $count = 0;
        $id_suffix = 1;
        $items_per_row = 4;
        $quality = 90;
        $paged = (get_query_var('page')) ? get_query_var('page') : 1;
        $my_query = new WP_Query( array( 
        'posts_per_page' => 8, 
        'post_type' => 'portfolio',
        'paged' => $paged
        ) );
        $grid_class = 'grid_3';
        $desired_width = 220;
        $desired_height = 190;
        $terms = get_terms( 'portfolio_categories' ); 
        $count_terms = count( $terms ); 
    ?>
    

    //Some php code

    <?php while ( $my_query -> have_posts()) : $my_query -> the_post(); //query the "portfolio" custom post type for portfolio items ?>
    
    
      (Some more php code)
    
    <?php endwhile;
    wp_pagenavi(array( 'query' => $my_query ) );    ?>
    </ul><!-- END .portfolio-gallery -->
    

    ?>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may be an extremely easy question but I can't get my head around
This may sound easy, but please, I am a newbie. I have a simple
Sorry if this question may seem easy to some but i cannot seem to
This should be easy, but I cannot seem to get it right as I
I am fairly new to OSX development, so this may be easy but google
This may be an easy answer but I've been staring at it for too
This may be super easy to solve but I can't find the correct google
This may seem an easy question, but not to me, also a search has
This may be a stupid question but I have a code with the following
This may be have a better name than custom tab completion, but here's the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.