$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>featured image metabox not moving custom post type|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

featured image metabox not moving custom post type

matteradmin11PV0评论

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”.
Post a comment

comment list (0)

  1. No comments so far