Horje
pagination with custom query with permalinks in functions.php - Wordpress Solution
Hi, I've spent all day trying to figure this out, I've done all the tutorials that I could find on the web, but I still can't get the pagination to work properly. WP-PageNavi shows 3 pages (there are 19 posts total) and the limit per page is 7, but when clicking on the nav buttons just reloads the same posts. this is an example of the problem: http://www.dekritischebelegger.nl/archives /category/Aandelen/2010/05/page/3/ I have used this code to get archives by category http://www.jayminkapish.com/2009/06/16/date-archive-for-a-category/ but I modified it to suit my needs. Anyway, it doesn't say anything about pagination


function my_date_archive_for_category() {

...
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
	query_posts(array(
		'cat' => $category_array["term_id"],
		'year'=> $request_parts["4"],
		'monthnum'=>$request_parts["5"],
		'paged' => $paged
	));

	if ( have_posts() ) :

	  while ( have_posts() ) : the_post(); ?>
		<div <?php post_class() ?>>
<?php global $post; ?>

	<?php endwhile; ?>

<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>
<?php		
	else:
		$is404 = true;
	endif;
		}
	else {
		$is404 = true;
	}
	}
	else {
		$is404 = true;
	}

	if($is404) {
		include(TEMPLATEPATH . '/404.php');
		} ?>
	</div><!--end for left-r-->

	</div>

	<div id="right">
		<?php get_sidebar(); ?>
	</div>

	</div>

<?php get_footer();
		exit;
	}
}

add_action('init','my_date_archive_for_category');
I haven't posted all the code, but I attached the functions.php file

Solution - 1

after the function query_posts run please make

var_dump($GLOBALS['wp_query'])
to debug variables that passed to the query_posts


Solution - 2

Looks like a simple typo maybe?

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts(array( 'cat' => $category_array["term_id"], 'year'=> $request_parts["4"], 'monthnum'=>$request_parts["5"], 'paged' => $paged ));
Give that a shot, maybe?





Wordpress

Related
Title showing up in body of post - Wordpress Solution Title showing up in body of post - Wordpress Solution
WP Admin White Screen - Wordpress Solution WP Admin White Screen - Wordpress Solution
User Photo in Get Recent Comments Widget - Wordpress Solution User Photo in Get Recent Comments Widget - Wordpress Solution
Backend-Pages with Frontend-Themes (Again!) - Wordpress Solution Backend-Pages with Frontend-Themes (Again!) - Wordpress Solution
 fatal error call to undefined function when uninstalling plugins - Wordpress Solution fatal error call to undefined function when uninstalling plugins - Wordpress Solution

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
6