ShareDaddy使用两个过滤器挂钩the_content
或the_excerpt
这意味着您的自定义帖子类型主题模板文件必须使用这两个函数之一the_content();
或the_excerpt();
.
更新
好的,我想我没有回答这个问题。因此,要将metabox添加到自定义帖子类型,请添加以下内容:
// Hook things in, late enough so that add_meta_box() is defined and make sure you already registered you post type.
if (is_admin()){
add_action( \'admin_init\', \'add_plugin_meta_boxes\' );
add_action( \'save_post\', \'save_sharing_box\' );
}
// This function tells WP to add the sharing "meta box"
function add_plugin_meta_boxes() {
add_meta_box( \'sharing_meta\', __( \'Sharing\', \'sharedaddy\' ), \'sharing_meta_box_content\', \'CUSTOM POST TYPE NAME\', \'advanced\', \'high\' );
}
function save_sharing_box( $post_id ) {
if ( defined(\'DOING_AUTOSAVE\') && DOING_AUTOSAVE )
return $post_id;
// Record sharing disable
if ( \'CUSTOM POST TYPE NAME\' == $_POST[\'post_type\'] ) {
if ( current_user_can( \'edit_post\', $post_id ) ) {
if ( isset( $_POST[\'sharing_status_hidden\'] ) ) {
if ( !isset( $_POST[\'enable_post_sharing\'] ) )
update_post_meta( $post_id, \'sharing_disabled\', 1 );
else
delete_post_meta( $post_id, \'sharing_disabled\' );
}
}
}
return $post_id;
}
和更改
CUSTOM POST TYPE NAME
给您实际的自定义帖子类型名称。