I do have a problem with a custom post pagination. I search through this site and googled the whole day yesterday, and found nothing that was similar to what I experience (or I'm getting blind...).
Here is my custom post "recipe":
register_post_type( 'recipe', array(
'labels' => array(
'name' => __('Recipes'),
'singular_name' => __('Recipe'),
'add_new' => __('Add New'),
'add_new_item' => __('Add new Recipe'),
'view_item' => __('View Recipe'),
'edit_item' => __('Edit Recipe'),
'new_item' => __('New Recipe'),
'view_item' => __('View Recipe'),
'search_items' => __('Search Recipes'),
'not_found' => __('No Recipes found'),
'not_found_in_trash' => __('No Recipes found in Trash'),
),
'public' => true,
'show_ui' => true,
'hierarchical' => true,
'supports' => array('title', 'editor', 'thumbnail'),
'menu_position' => 100,
'menu_icon' => get_stylesheet_directory_uri() . '/images/icon_recipe.png',
'rewrite' => array(
"slug" => "recipe",
"with_front" => false,
"pages" => true
)
) );
I need to load 6 recipes on my recipe page, and then I use jQuery to load the next 6 in AJAX. The code actually grab the "next page" URL (that is hidden in my page) to perform this.
The problem is that it keeps loading the first 6 recipes, despite the fact that the url is correct (/recettes/page/2/).
When I try to load this page directly in the address bar, it redirects to /recettes/ (that is my first page). Even when I put a die("test") at the top of my template file, it never gets there. Could it be only related to the URL rewriting?
Here is my .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
The strange thing is that the same mechanism works for the news section... Any ideas? Thanks a lot for your help!
Matt
PS: here is the page, if you want to have a look: http://www.francoischartier.ca/recettes/
PPS: and this is the news section that works: http://www.francoischartier.ca/chartier/nouvelles/
Here is the query in the page template for recipes:
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'recipe',
'posts_per_page' => 6,
'order' => 'ASC',
'orderby' => 'post_title',
'tax_query' => array(),
'paged' => $paged,
'caller_get_posts' => 1
);