Adding the plugin to a custom post
-
The plugin only supports ‘post’ and ‘page’ post types. The plugin can be added to another post type by adding code like that below to you theme’s functions.php file.
add_action('add_meta_boxes', 'lsl_add_custom_box_dd_ratings'); function lsl_add_custom_box_dd_ratings() { // Check the plugin is activated if (!function_exists('dd_rating_custom_box')) return; $custom_post_slug = 'download'; add_meta_box( 'ratings', __('Ratings', 'ratings'), 'dd_rating_custom_box', $custom_post_slug, 'advanced', 'high' ); }
The value assigned to the variable $custom_post_slug is the slug of the custom post. If the custom post type is created by the vendor of another plugin the slug will be the name immediately following the blog site address in the browser address bar. In the example the slug is ‘download’ which is the name of custom posts of Easy Digital Downloads.
The function does not need to be ‘lsl_add_custom_box_dd_ratings’. It can be any unique name you choose. However any alternative name you choose must also appear in the second parameter passed to the ‘add_action()’ function.
- The topic ‘Adding the plugin to a custom post’ is closed to new replies.