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 |
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. |
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); }