Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Montezuma Theme »

[SOLVED] bfa_custom_query Pagination


  #1  
Old Feb 18, 2015, 09:19 AM
CrouchingBruin's Avatar
CrouchingBruin
 
299 posts · Aug 2010
Santa Monica, CA
The function bfa_custom_query was added to the theme in version 1.2.2. As the name suggests, the function allows you to create your own custom queries. For example, if you want an index/blog page that displayed the posts from four different categories, it is now easy to do. I've discovered a problem, however, with the way the function handles pagination.

For custom queries which return a number of posts that is larger than what has been set for the page size, the pagination control displays the correct number of tabs. For example, if the query returns 25 posts, then three tabs are displayed: 1, 2 & 3. The first two pages should display 10 posts each and the last page should display five posts. However, clicking on any of the pagination tabs displays the posts from the first page and not the posts for the corresponding page. The URL is correct for the page (e.g., /page/2/) but the page displays the posts from the first page and not the posts for the page being viewed.

The cause of the problem is described in the Wordpress codex for query_posts:
Quote:
Pagination won't work correctly, unless you set the 'paged' query var appropriately: adding the paged parameter
If you follow the link to the codex page for adding the paged parameter to a query, it describes how to call the get_query_var to retrieve the correct page number:
Quote:
If query_posts or WP_Query is altering the main loop and the "paged" parameter is not set you'll need to add it with get_query_var(). This is so WordPress knows exactly what page it's on.
Since I can't call get_query_var from the virtual templates, I fixed the problem by making the following change to the bfa_custom_query function in the /includes/template_tags.php file:
Code:
function bfa_custom_query( $bfa_custom_query = '') {
	wp_reset_query();
	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
	query_posts( $bfa_custom_query . '&paged=' . $paged);

}
Pagination now works correctly.
__________________
My Montezuma-themed sites: ESHS Girls Basketball Team, Venice Hongwanji Buddhist Temple
Please consider making a donation to BytesForAll for their great themes!
  #2  
Old Feb 18, 2015, 10:24 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
Thank you for the find and the fix, I'll pass it along.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shorter pagination (menu) bar Bruno Montezuma Theme 3 Jan 22, 2015 08:53 AM
Pagination not working immora Montezuma Theme 4 Jan 24, 2013 08:05 AM
Would like to Add Pagination? theadventurebite Excerpts, Read more, Pagination 0 Jul 26, 2012 10:41 PM
Pagination and RSS feed broken... silvershield RSS, Feeds & Subscribing 19 May 12, 2011 04:15 PM
1, 2, 3, 4, 5 Pagination instead of Next/Previous Jurgen Estanislao Excerpts, Read more, Pagination 0 Aug 17, 2010 08:50 AM


All times are GMT -6. The time now is 05:38 AM.


Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.