• 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

Excluding Pages but adding pagination from a custom loop that uses WP_query

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 › Excluding Pages but adding pagination from a custom loop that uses WP_query

This topic is: not resolved

Tagged: loop, templates

  • This topic has 1 reply, 2 voices, and was last updated 11 years, 6 months ago by Brad Dalton.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • September 7, 2014 at 6:12 am #123124
    aryon
    Member

    First time working with the loop and have almost everything working with two custom templates.

    Home Page Issue: Link
    - I need to update the Query to not call Pages.
    - Also need the pagination to show up after the 15th post in the left column.

    // Add our custom loop
    add_action( 'genesis_loop', 'pg_home_loop' );
    
    function pg_home_loop() {
    	global $post;
    
    	$paged = (get_query_var('paged')) ? get_query_var('post_type=any') : 1;
    	
    	global $only_query;
    	$only_query = new WP_Query( 'paged=' . $paged . '&offset=1');
    
    	// Pagination fix
    	$temp_query = $wp_query;
    	$wp_query   = NULL;
    	$wp_query   = $only_query;
    
    		if( $only_query->have_posts() ) :
    	 		$i = 1;

    Category template is calling the correct posts but the pagination keeps returning the same posts when you navigate to Page 2 or older: http://pyragraph.staging.wpengine.com/category/art/

    			}
    
    	 		$i++;
    	 		
    			endwhile;
    			
    			do_action( 'genesis_after_endwhile' );
    			//genesis_posts_nav();
    						
    		endif;
    		
    	wp_reset_query();
    
    	// Reset main query object
    	$wp_query = NULL;
    	$wp_query = $temp_query;
    }
    
    genesis();
    http://pyragraph.staging.wpengine.com/
    September 8, 2014 at 1:18 am #123299
    Brad Dalton
    Participant

    Use the default loop and pre_get_posts to alter it if you can.


    Tutorials for StudioPress Themes.

  • 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

© 2026 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