• 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

Can't get pagination to work

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 › General Discussion › Can't get pagination to work

This topic is: not resolved

Tagged: pagination

  • This topic has 8 replies, 3 voices, and was last updated 7 years, 8 months ago by Brad Dalton.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • January 19, 2016 at 3:39 pm #176960
    beth_know
    Member

    I've tried everything I can think of to get pagination working on a page I have in a child theme. Can anybody point me in the right direction of where I can figure this out? I'm working with somebody else's code and am unfamiliar with Genesis in general, so I'm already pretty far behind in what I understand and don't with this code. Just super frustrated today!

    I'm including a gist of the page template, but don't even know if what I need to adjust is in the template or in functions or ???

    http://www.brandt-realestate.com/closed/
    January 19, 2016 at 6:30 pm #176975
    carasmo
    Participant

    I'm not sure this will work, but first check that you have numeric pagination chosen in your theme settings:

    wp-admin > Genesis > Theme Settings

    Then scroll to "Content Archives" and choose Numeric Pagination and click save.

    Image

    Then use FTP to download your functions.php file. Make a copy of it and name it bu-functions_19-12-16_9-pm.php (change the date and time) and then edit the original functions.php with a code editor and add this following code but change the string between the tick marks from 'your-page-template.php' to the the name of the page you posted, like 'sold-featured.php'. Make sure you are after any other existing functions in this file and dont use a word processer, use a code editor, then reload the file and re-fresh the page. If it's messed up, then put back the old functions.php file and hopefully someone else will come along to help out.

    /* ------ posts per archive "sold"  ----- */
    function sold_posts_per_page( $query ) {
    
    if (!is_admin() && is_archive() && is_category( '9' ) && is_page_template( 'your-page-template.php' ) )
            
            $query->set( 'posts_per_page', 18 );
    
    }
    add_filter('parse_query', 'sold_posts_per_page');
    

    Genesis Theme Customization and Help

    January 19, 2016 at 6:34 pm #176978
    carasmo
    Participant

    also, I've never seen a Genesis custom page like that, all of them end with

    genesis();

    Which is missing from your template.

    If just

    genesis(); doesn't work

    Try

    
    <?php genesis(); ?> 

    Make sure there are NO empty returns after the end of the file.


    Genesis Theme Customization and Help

    January 20, 2016 at 8:28 am #177013
    beth_know
    Member

    Unfortunately, no go 🙁 Thanks for the suggestion, though.
    Where does Genesis set up the pagination function in the first place? Or what is the name of it? I think this is going to take a lot of untangling for me to figure out!

    January 20, 2016 at 10:08 am #177016
    carasmo
    Participant

    Here is what I use to start with.

    https://gist.github.com/billerickson/3218052

    Then I use the code used in the previous post (http://www.studiopress.community/topic/cant-get-pagination-to-work/#post-176975) to conditionally set the items per page (whether it's a CPT or a category etc.), otherwise it will be the amount in your WP readings settings and if they don't match, you'll get a 404 error. Read the comments on that page too.

    Whatever pagination is set in your settings in the Admin is used in the "genesis_after_endwhile" action. You can see it in your Genesis framework in the post.php file lines 643 - 662, it's called "genesis_numeric_posts_nav();"

    Do not modify your core framework.


    Genesis Theme Customization and Help

    January 20, 2016 at 10:11 am #177021
    carasmo
    Participant

    I have no clue why I can't link to a gist, so I stuck it in code ticks.


    Genesis Theme Customization and Help

    January 22, 2016 at 7:27 am #177164
    Brad Dalton
    Participant

    @carasmo

    Gists aren't easy to embed at the moment. Not sure why.

    I use opening and closing pre tags.


    @beth
    The genesis(): function includes all the markup and hooks. Without it, you need to add them back.


    Tutorials for StudioPress Themes & WooCommerce.

    January 22, 2016 at 9:17 am #177179
    beth_know
    Member

    Yes, had a hard time embedding mine as seen by the many edits!


    @brad
    : On none of the page templates that this guy built on any site do I see genesis() called anywhere. I'm assuming he's calling it from within another function somewhere, but I don't see where. If I add it at the end, it generates another instance of the page (mostly blank) underneath what's already there.

    Part of my problem is that I have no background in PHP, and am fairly new to coding in general. So while I can look at the code and follow along for the most part, writing my own is going to be tough. Doing lots of copy/pasting at the moment and learning by just jumping in. By doing that, I've at least got my dev instance of the site LOOKING like it has pagination happening even though it is not working yet. I've gathered that it's because it is using query_posts() - which I understand is not cool, but again I'm simply using what I find. Will try again to play with some of the Bill Erickson code as I have time.

    January 22, 2016 at 10:04 am #177188
    Brad Dalton
    Participant

    He's using get_header and get_footer which are already included in the genesis function.


    Tutorials for StudioPress Themes & WooCommerce.

  • Author
    Posts
Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘General Discussion’ 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