Support other Post Types
-
I want to start by saying thanks for this plugin! It does exactly what we needed it to do.
Something neat for this plugin to add though would be the ability to natively support other Post Types than just the “Posts” Post Type.
It can currently be done pretty easily using the following code:
add_filter("manage_{$post_type}s_columns", 'gapp_column_views'); add_action("manage_{$post_type}s_custom_column", 'gapp_custom_column_views', 6, 2); add_filter("manage_edit-{$post_type}_sortable_columns", 'gapp_manage_sortable_columns');
Where
{$post_type}
is your Post Type Slug.Having those Filters get added as part of a Loop could be helpful. I’m thinking an Array that can be Filtered so that devs can easily just append additional Post Types and then the Plugin will handle the rest.
So by default, it could be something like
// Allow additional Post Type Slugs to be provided via a Filter $post_types = apply_filters( 'gapp_post_types', array( 'post' ) ); foreach ( $post_types as $post_type ) { add_filter("manage_{$post_type}s_columns", 'gapp_column_views'); add_action("manage_{$post_type}s_custom_column", 'gapp_custom_column_views', 6, 2); add_filter("manage_edit-{$post_type}_sortable_columns", 'gapp_manage_sortable_columns'); }
Otherwise, adding additional Checkboxes or something to the Settings screen so that Users can quickly toggle which Post Types should show View Counts would be very useful.
- The topic ‘Support other Post Types’ is closed to new replies.