4

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?

2
  • Hi, thank you @Mayeenul. This is the method I've been currently using - and it works on wp 3.6, but I'm aware that contextual_help has been depreciated, and was looking for a way to implement the add_help_tab method and have it work on both the "custom_post_type" and "edit-custom_post_type" screens. I'm not sure how to mark this... Commented Sep 11, 2013 at 15:34
  • I just edited both the Q & A, not given the answer. :) The answer was given by Nat. You can comment on the answer to inform him/her about your experiment. Commented Sep 11, 2013 at 16:57

3 Answers 3

2

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');
0

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.

-1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.