Community Forums › Forums › Archived Forums › General Discussion › Can't get pagination to work
Tagged: pagination
- This topic has 8 replies, 3 voices, and was last updated 9 years, 1 month ago by
Brad Dalton.
-
AuthorPosts
-
January 19, 2016 at 3:39 pm #176960
beth_know
MemberI'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 #176975carasmo
ParticipantI'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');
January 19, 2016 at 6:34 pm #176978carasmo
Participantalso, 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 workTry
<?php genesis(); ?>
Make sure there are NO empty returns after the end of the file.
January 20, 2016 at 8:28 am #177013beth_know
MemberUnfortunately, 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 #177016carasmo
ParticipantHere 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.
January 20, 2016 at 10:11 am #177021carasmo
ParticipantI have no clue why I can't link to a gist, so I stuck it in code ticks.
January 22, 2016 at 7:27 am #177164Brad Dalton
ParticipantGists 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.
January 22, 2016 at 9:17 am #177179beth_know
MemberYes, 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 #177188Brad Dalton
ParticipantHe's using get_header and get_footer which are already included in the genesis function.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.