admin - Adding help information to custom post edit page

I have two custom post types created (using Types plugin) with a bunch of custom fields. I need to add a help informatio

I have two custom post types created (using Types plugin) with a bunch of custom fields.

I need to add a help information, instructions for admins that will show at the top of add new/edit CPT page of dashboard.

How can I add a text visible only on those two pages (add/edit post type 1 and add/edit post type 2)?

I have two custom post types created (using Types plugin) with a bunch of custom fields.

I need to add a help information, instructions for admins that will show at the top of add new/edit CPT page of dashboard.

How can I add a text visible only on those two pages (add/edit post type 1 and add/edit post type 2)?

Share Improve this question asked Jan 1, 2014 at 13:48 GacekGacek 1971 gold badge3 silver badges14 bronze badges
Add a comment  | 

4 Answers 4

Reset to default 4

Try this:

function options_instructions_example() {
    global $my_admin_page;
    $screen = get_current_screen();

    if ( is_admin() && ($screen->id == 'custom_post_type_name') ) {

        function add_content_after_editor() {
            global $post;
            $id = $post->ID;
            echo '<div class="postbox" style="background:#0074a2;color:#fff;margin-top:20px;"><div class="inside">';
            echo 'Instructions go here.';
            echo '</div></div>';
        }
        add_action( 'edit_form_after_title', 'add_content_after_editor' );
    }
}
add_action( 'admin_notices', 'options_instructions_example' );

It will result in something that looks similar to this: https://i.sstatic/5rU66.png

You can also add meta boxes with the content, which help the users. This is more useful. The writers can hide this box and set their personal options to hide the hints from you, if is not necessary for the writers. To add the boxes to the different post type use the specific hooks: add_meta_boxes_xxx, xxx is for the post type 1 and post type 2.

Small hint to identifier hooks use the plugin Debug Objects, list Hooks and screen info to find the right anchor.

A screenshot say more, how I find the hook.

You can add the help text above the meta boxes in the Edit Screens easily when using a plugin like ACF or Types.

Accomplish it by using edit_form_top hook. Code -

add_action('edit_form_top', 'wpse128204_edit_form_top');
function wpse128204_edit_form_top( $post )
{
    if( in_array( $post->post_type, array( 'post type 1', 'post type 2' ) ) ){
        // You want to do something here
    }
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745552312a4632632.html

相关推荐

  • admin - Adding help information to custom post edit page

    I have two custom post types created (using Types plugin) with a bunch of custom fields. I need to add a help informatio

    21小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信