Adding Help Tabs To Custom Post Types

Using this well written post – tutorial Edit dashboard’s help tab I have full control over all standard WordPress admin screens.

Can this be modified to add “Help” Tabs to custom post types?

Related posts

3 comments

  1. Use this code for solve your Problem.

    function custom_help() {
        global $post_ID;
        $screen = get_current_screen();
    
        if( isset($_GET['post_type']) ) $post_type = $_GET['post_type'];
        else $post_type = get_post_type( $post_ID );
    
        if( $post_type == 'listing' ) :
    
        $screen->add_help_tab( array(
            'id' => 'you_custom_id', // unique id for the tab
            'title' => 'Custom Help', // unique visible title for the tab
            'content' => '<h3>Help Title</h3><p>Help content</p>', //actual help text
        ));
    
        $screen->add_help_tab( array(
            'id' => 'you_custom_id_2', // unique id for the second tab
            'title' => 'Custom Help 2', // unique visible title for the second tab
            'content' => '<h3>Help Title 2</h3><p>Help content</p>', //actual help text
        ));
    
        endif;
    
    }
    
    add_action('admin_head', 'custom_help');
    
  2. The method of Adding Help Tabs described here Edit dashboard’s help tab also works for custom posts types as long as the edit-CustomPostType function (list admin screen) occurs before the CustomPostType function (edit / add new admin screen). For custom post type taxonomies use edit-taxonomyName. Cheers.

  3. I actually happened to bump into this answer yesterday on this tutorial:

    Just change “product” on line 2 to suite your needs.

    The contextual help feature is a descending tab which can be seen in the top right of pages where available. Let’s take a look at how the contents can be changed.

    function my_contextual_help( $contextual_help, $screen_id, $screen ) { 
        if ( 'product' == $screen->id ) {
    
            $contextual_help = '<h2>Products</h2>
            <p>Products show the details of the items that we sell on the website. You can see a list of them on this page in reverse chronological order - the latest one we added is first.</p> 
            <p>You can view/edit the details of each product by clicking on its name, or you can perform bulk actions using the dropdown menu and selecting multiple items.</p>';
    
        } elseif ( 'edit-product' == $screen->id ) {
    
            $contextual_help = '<h2>Editing products</h2>
            <p>This page allows you to view/modify product details. Please make sure to fill out the available boxes with the appropriate details (product image, price, brand) and <strong>not</strong> add these details to the product description.</p>';
    
        }
        return $contextual_help;
    }
    add_action( 'contextual_help', 'my_contextual_help', 10, 3 );
    

    The codes above will generate dynamic help tabs based on the screen->id, this essential when you want to show help tab only in a particular admin page or in your case a CPT, just target the slug og the CPT.

Comments are closed.