Next/Previous page function not working after 3.4 update
-
I updated to 3.4 and now the page navigation is not working. When you click on a page number or the ‘next’ button I get a 404 error. I’m using the WP-PageNavi plugin (http://wordpress.org/extend/plugins/wp-pagenavi/). the strange thing is is that I have another WP blog with the same plugin running 3.4 and it is working fine. Any help is appreciated.
-
Do you use custom posts? what’s the site address?
WP-PageNavi plugin does not seem to be compatible with WordPress 3.4
Compatible up to: 3.3.2
Last Updated: 2012-4-18Deactivate the plugin and see if the problem persists.
zex2911: I do use custom posts the address to the site is randomredboxreviews.com, my other site that is running 3.4 and the plugin is geekitupradio.com,
Krishna: I would deactivate the plugin, but would have no way of testing without it since it is the only thing that I use for page navigation on the site.
If it helps I’m using a customized version of the Dione theme.
If you made custom posts, go to functions.php and find line that has rewrite rule for custom post you are using. It should look similar to this:
'rewrite' => array( 'slug' => '#', 'with_front' => true )
where # = your custom post in plural (on my site, for custom portfolio item, is portfolios).Found the line:
‘rewrite’ => array( ‘slug’ => ‘genre’ ),
What do I do now?
try to change it to
'rewrite' => array( 'slug' => 'genres', 'with_front' => true ),
and also check do you haveflush_rewrite_rules();
under register_post_type lineTried changing
'rewrite' => array( 'slug' => 'genre' ),
to'rewrite' => array( 'slug' => 'genres', 'with_front' => true ),
and had no effect. Theflush_rewrite_rules();
is not under the register_post_type, is there any place in particular that line should go?register_post_type( 'videos', array( 'public' => true, 'publicly_queryable' => true, 'hierarchical' => false, 'menu_icon' => get_stylesheet_directory_uri() . '/images/video.png', 'labels'=>array( 'name' => _x('Videos', 'post type general name'), 'singular_name' => _x('Video', 'post type singular name'), 'add_new' => _x('Add New', 'video'), 'add_new_item' => __('Add New video'), 'edit_item' => __('Edit video'), 'new_item' => __('New video'), 'view_item' => __('View video'), 'search_items' => __('Search video'), 'not_found' => __('No videos found'), 'not_found_in_trash' => __('No videos found in Trash'), 'parent_item_colon' => '' ), 'show_ui' => true, 'menu_position'=>5, 'supports' => array( 'title', 'editor', 'author', 'post-thumbnails', 'excerpts', 'trackbacks', 'custom-fields', 'comments', 'revisions') ) );
Ok, just tried this, and it works on my localhost. Hopefully it will work for you.
add_action('init', 'video_register'); function video_register() { register_post_type( 'videos', array( 'public' => true, 'publicly_queryable' => true, 'hierarchical' => false, 'menu_icon' => get_stylesheet_directory_uri() . '/images/video.png', 'labels'=>array( 'name' => _x('Videos', 'post type general name'), 'singular_name' => _x('Video', 'post type singular name'), 'add_new' => _x('Add New', 'video'), 'add_new_item' => __('Add New video'), 'edit_item' => __('Edit video'), 'new_item' => __('New video'), 'view_item' => __('View video'), 'search_items' => __('Search video'), 'not_found' => __('No videos found'), 'not_found_in_trash' => __('No videos found in Trash'), 'parent_item_colon' => '' ), 'show_ui' => true, 'menu_position'=>5, 'rewrite' => array( 'slug' => 'videos', 'with_front' => true ), 'capability_type' => 'post', 'supports' => array( 'title', 'editor', 'author', 'post-thumbnails', 'excerpts', 'trackbacks', 'custom-fields', 'comments', 'revisions') ) ); flush_rewrite_rules(); }
If that doesn’t help, we will try again. 🙂
I added what you posted above, it still doesn’t work and I get this line at the top of the page “Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, ‘post_type_videos’ was given in /homepages/2/d130186665/htdocs/randomredbox/wp-includes/plugin.php on line 403”
Line 403 in the plugin.php is
call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
Any other suggestions, or is there another page navigation plugin that might work?
Just wanted to update this, I’ve tried two other plugins (Simple Pagination and WP-PageNavi-LightWord) that do the same thing and am getting the same error.
I’m sorry for not being able to help you, but i don’t know what else to try. 🙁
Will try again tomorrow… 🙂No problem zex2911. I actually got it to work again! I was looking around on the site from where I got the theme from and found a similar theme. The comments on the theme were about the same issue that I was having and they posted code to paste into the functions.php file. Put that in there and everything is working fine now! Thanks for your help.
Here’s the code that was put in:
function my_query_for_homepage( $query ) { if( $query->is_main_query() && $query->is_home() ) { $query->set( 'post_type', array( 'videos' ) ); } } add_action( 'pre_get_posts', 'my_query_for_homepage' );
Fixed my issue, that code helped. Thanks.
- The topic ‘Next/Previous page function not working after 3.4 update’ is closed to new replies.