WordPress Custom post type and pagination problem – Error 404

Sunday, December 11, 2011 0:26
Posted in category Wordpress

1.5hour of pure frustration.

After registering a custom post type, slug “news”, and creating a page “news” to display the latest posts the pagination just wouldn’t work. I was always getting a 404 error. Setting the permalinks to default and back to the old setting solved the problem.

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$wp_query = new WP_Query("post_type=news&paged=$paged&posts_per_page=1");

if (have_posts()) :


WordPress 3.1 supports archive pages for custom post types. Add “has_archive” => true when creating the custom post type. No custom page required any more. Name the archive page: archive-customPostTypeName.php

Paging still has problems. Setting the default wordpress posts per page value lower or same as the custom wp_query(“posts_per_page”) value solves this somehow. Weird.

You can leave a response, or trackback from your own site.

Leave a Reply

Connect with Facebook