Wordpress Themes - WP Forum at BFA
Click here to register or to donate.
Auto self-registration is not available here - far too many spammers. This forum has many, many backlinks and because of that there is an intense desire among spammers to drop their links here.

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

[SOLVED] bfa_custom_query Pagination

Old Feb 18, 2015, 09:19 AM
CrouchingBruin's Avatar
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:
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:
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:
function bfa_custom_query( $bfa_custom_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!
Old Feb 18, 2015, 10:24 AM
juggledad's Avatar
23,743 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


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 07:48 PM.

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