featured image metabox not moving custom post type

admin2025-06-03  3

I am working on theme development and I have to move my featured image metabox so that it is more user friendly. I searched for move featured image metabox.

Thanks Allah for I have found the solution

For a test I found that the problem is that it works for "post" post type not custom post type

# Information

WP version: 5.0.3 PHP version: 7.2.11 I am using Laragon

# This is the code

add_action('do_meta_boxes', 'ppdc_screenshot_move_metabox' );

function ppdc_screenshot_move_metabox() {
    remove_meta_box( 'postimagediv', 'ppdc-screenshot', 'side' );
    add_meta_box('postimagediv', 'Screenshot Image', 'post_thumbnail_meta_box', 'ppdc-screenshot', 'normal', 'high');
}

I am working on theme development and I have to move my featured image metabox so that it is more user friendly. I searched for move featured image metabox.

Thanks Allah for I have found the solution

For a test I found that the problem is that it works for "post" post type not custom post type

# Information

WP version: 5.0.3 PHP version: 7.2.11 I am using Laragon

# This is the code

add_action('do_meta_boxes', 'ppdc_screenshot_move_metabox' );

function ppdc_screenshot_move_metabox() {
    remove_meta_box( 'postimagediv', 'ppdc-screenshot', 'side' );
    add_meta_box('postimagediv', 'Screenshot Image', 'post_thumbnail_meta_box', 'ppdc-screenshot', 'normal', 'high');
}
Share Improve this question edited Feb 12, 2019 at 23:11 rudtek 6,4035 gold badges30 silver badges52 bronze badges asked Feb 12, 2019 at 22:24 NobirNobir 31 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

Hope this code may be help you.

You can read the full parameters for add_meta_box in the codex. I also listed them here:

add_meta_box( $id, $title, $callback, $page, $context, $priority, $callback_args );

function wpt_add_event_metaboxes() {
    add_meta_box(
        'wpt_events_location',      // $id
        'Event Location',           // $title
        'wpt_events_location',      // $callback
        'events',                   // $page (Post Type)
        'side',                     // $context
        'default'                   // $priority
    );
}
add_action( 'add_meta_boxes', 'wpt_add_event_metaboxes' );

For the example above:

  • $id is “wpt_events_location”- or the html id that will be applied to this metabox.
  • $title is “Event Location”. This appears at the top of the new metabox when displayed.
  • $callback is the function “wpt_events_location” which will load the html into the metabox.
  • $page is “events”, the name of our custom post type.
  • $context is “side”. If you wanted it to load below the content area, you could put “normal”.
  • $priority controls where the metabox will display in relation to the other metaboxes. You can put “high”, “low” or “default”.
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748913208a314762.html

最新回复(0)