-
-
Notifications
You must be signed in to change notification settings - Fork 4
Changing the editor availability per post type
Boia Alexandru edited this page Dec 9, 2022
·
4 revisions
Normally, the WP Trip Summary editor is available only for post
and page
post types.
However, as of 0.2.8, you can alter this behavior by using the abp01_trip_summary_available_for_post_types
filter.
The filter has only one parameter, the current list of post types for which the editor is enabled.
You don't have to do any work to get it displayed, since the trip summary viewer will only be rendered if there is any actual data to go on.
function e01_get_trip_summary_available_for_post_types($postTypes) {
//Of course, you could also remove
// an existing post type over here
$newPostTypes = $postTypes;
if (!in_array('e01_sample_post_type', $newPostTypes)) {
$newPostTypes[] = 'e01_sample_post_type';
}
return $newPostTypes;
}
function e01_init() {
add_filter('abp01_trip_summary_available_for_post_types',
'e01_get_trip_summary_available_for_post_types',
1);
}
add_action('init', 'e01_init');
This is a snippet taken from one of the examples for achieving just that. Check it out here