• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

pagination with genesis_after_endwhile

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › pagination with genesis_after_endwhile

This topic is: resolved

Tagged: pagination

  • This topic has 1 reply, 1 voice, and was last updated 6 years, 2 months ago by hp.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • August 21, 2019 at 6:04 am #493067
    hp
    Member

    I have this function, but there is no pagination. I have 5 posts in this category, and posts_per_page is 3. Wondering if I am doing something wrong? Please suggest. Thank you.

    function camnghi() {
    
      if ( get_query_var( 'paged' ) ) { $paged = get_query_var( 'paged' ); }
      elseif ( get_query_var( 'page' ) ) { $paged = get_query_var( 'page' ); }
      else { $paged = 1; }
    
      $args = array ( 'cat' => '987',
                    'paged' => $paged,
                     'posts_per_page' => '3'
                    );
    
      $wp_query = new WP_Query( $args );
      if ( $wp_query->have_posts() ) :
          $i=1;
          while ( $wp_query->have_posts() ) :
              $wp_query->the_post();
              echo '<div class="luubut-wrap">';
                if ( $i%2 ) {
                  echo '<div class="one-fourth first">';
                    the_post_thumbnail();
                  echo '</div>';
                  echo '<div class="three-fourths">';
                    the_content();
                    echo '<span class="ten-luubut">'.get_the_title().'</span>';
                  echo '</div>';
                }
                else {
                  echo '<div class="three-fourths first">';
                    the_content();
                    echo '<span class="ten-luubut">'.get_the_title().'</span>';
                  echo '</div>';
                  echo '<div class="one-fourth">';
                    the_post_thumbnail();
                  echo '</div>';
                }
              echo '</div>';
              $i++;
          endwhile;
          do_action( 'genesis_after_endwhile' );
    
      endif;
      wp_reset_postdata();
    
    }
    August 21, 2019 at 6:15 am #493068
    hp
    Member

    Found the reason. Need to have "global $wp_query;" first. However, now, the page 2 shows 404 error. Any idea, please?

    Thanks.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble