This is how to extend it to support custom post types (Events, etc.)
-
Hi all,
This is amazing plugin, that can be easily extended to support custom post types like Events, Projects, etc.
Do the following:
1. Open plugin folder and find file edit-next-previous-post-admin.php;
2. Find function amm_edit_next_prev_post_button() in this file;
3. Find line $supported_types = array(‘page’, ‘post’); in this function;
4. Now replace line
$supported_types = array('page', 'post');
with line
$supported_types = array('page', 'post') + get_post_types(array('public' => true, '_builtin' => false), 'names', 'and');
This will add Previus/Next buttons to all custom post types you have registered in your WP instance.
Code explained: get_post_types() in built-in WP function to retrieve all registered post types. With first argument we filter out only public post types that are NOT system types (this is because we already have listed ‘page’ and ‘post’ type earlier, and we do not want other types like menues or revisions). This function returns array, so we add it to array defined by author.
Enjoy!
Thank you Aftab Muni for this great plugin!
Please extend it with my code to cover also custom post types in next version.
- The topic ‘This is how to extend it to support custom post types (Events, etc.)’ is closed to new replies.