Add Content To Help Tab In WordPress

Wordpress PHP net

Add Content To Help Tab In WordPress

A very useful feature on the Adminstrative Panels is the Help Tab. It is located on the right side of the page just above the ‘Publish’ metabox.

wordpress help tab

If you need to add some content to help the user ( Set the Featured Image in a Post as an example) we can use the add_meta_box function to do this. We use a Conditional statement to check for the $screen->id. If we were creating a new Post, the ‘Add New Post’ page has a $screen->id = 'post'. The content is added using add_help_tab() function. Also, instead of writing our content in this function ( which can make it messy ), I create a separate file and use the file_get_contents() function to get the content.

 

// Add Contextual help tab to the Edit Post help tab
add_action( ‘add_meta_boxes’ ) , ‘dh_add_help_tab’ , 10 , 2 );
function dh_add_help_tab ( $post_type , $post ) {
if ( ‘post’ == $post_type ) {

get_current_screen()->add_help_tab( array )(
‘id’ => ‘dh_help_tab’,
‘title’ => __( ‘ Help Tab’ ),
‘content’ => __( file_get_contents( get_stylesheet_directory_uri() . ‘/lib/help/help-tab.html’ ) ),
));
}
}