问题
I know how to add meta boxes to pages/posts/custom_post_type ($post_type) pages:
$screens = array( 'post', 'page' );
foreach ( $screens as $screen ) {
add_meta_box(
'myplugin_sectionid',
__( 'My Post Section Title', 'myplugin_textdomain' ),
'myplugin_meta_box_callback',
$screen
);
}
but how do i add a meta box to the pages-overview? i need a link-list there to some special pages ...
I know there are plugins who can do this: http://wordpress.org/plugins/meta-box/screenshots/ but only on posts/pages edit screen, like any tutorial i have found.
回答1:
You can add stuff to a column in that screen using the filter "manage_edit-{$cpt}_columns"
and the action "manage_{$cpt}_posts_custom_column"
:
And it is possible to catch form submissions using:
add_action( 'load-edit.php', 'load_edit_so_23561386' );
function load_edit_so_23561386()
{
global $typenow;
$cpt = 'post';
if( $typenow !== $cpt )
return;
if( isset( $_POST['YOUR-FORM'] ) )
do_your_stuff();
}
But as there are multiple posts (virtually 999), it's much better to use AJAX, but that's a whole other story.
来源:https://stackoverflow.com/questions/23561386/wordpress-add-custom-meta-box-to-pages-overview-not-only-to-posts-pages