• 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 Mess

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 Mess

This topic is: resolved

Tagged: archive, custom loop, pagination

  • This topic has 4 replies, 3 voices, and was last updated 9 years, 10 months ago by vajrasar.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • November 28, 2013 at 4:37 am #76007
    vajrasar
    Member

    1> Registered a CPT 'events'

    2> created archive-events.php

    Problem - There are total 13 posts as published. It should show 5 posts on page one (i.e. on mysite.com/events), then 5 on page 2 and remaining 3 posts on page 3. But instead it shows 404 on page 3.

    I first used this custom query code, but same problem ->

    But then I thought, that maybe I should try this code, still the same problem ->

    Any idea on why is this happening? Thanks a ton.


    I make WordPress websites using Genesis Framework.

    WordPress/Genesis Development | Customizations

    November 28, 2013 at 6:59 am #76020
    Brad Dalton
    Participant

    Link to your site please.

    The best way to create a CPT is to use the code from the Executive Pro theme.


    Tutorials for StudioPress Themes & WooCommerce.

    November 28, 2013 at 7:03 am #76021
    vajrasar
    Member

    CPT Code -

    *************************************************

    link - udaipurtimes.com/events

    you have to use /page/2 and /page/3 method in url and right now we have disabled infinite scroll on this cpt archive.


    I make WordPress websites using Genesis Framework.

    WordPress/Genesis Development | Customizations

    November 28, 2013 at 9:01 am #76037
    Sridhar Katakam
    Participant

    Instead of a template file for the Events archive, why not just add this in functions.php?

    add_action( 'pre_get_posts', 'sk_events_archive' );
    function sk_events_archive( $query ) {
    
    	if( $query->is_main_query() && !is_admin() && $query->is_post_type_archive( 'events' ) ) {
    		$query->set( 'posts_per_page', '5' );
    	}
    
    }

    Tested and working fine. I used Types plugin to create the CPT.


    Genesis Tutorials | Follow me on Twitter

    November 29, 2013 at 2:34 am #76125
    vajrasar
    Member

    @Sridhar: Thanks for this, it was something new that I learnt.

    Now, this dosen't work on our site. But I think I got the grip on the 'problem'.

    It's that - If I keep number of posts blank (dont provide any parameter) then it takes the default sitewide value of 10 posts per page and works fine. But as soon as I want to alter it to 5 or 6 posts per page, the problem arises.


    I make WordPress websites using Genesis Framework.

    WordPress/Genesis Development | Customizations

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 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

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