【问题标题】:Custom function to change the excerpt title and a post thumbnail in a custom post type自定义功能以更改自定义帖子类型中的摘录标题和帖子缩略图
【发布时间】:2012-09-14 08:47:26
【问题描述】:

我想自定义摘录文本以使其更接近我的自定义帖子类型,因此我决定删除元框并重新创建它们。我在我的functions.php中使用了这段代码:

function custom_post_type_boxes(){
    remove_meta_box( 'postimagediv', 'alma_client', 'side' );
    add_meta_box( 'postimagediv', __( 'Client logo' ), 'post_thumbnail_meta_box', 'alma_client', 'normal', 'high' );
    remove_meta_box( 'postexcerpt', 'alma_client', 'normal' );
    add_meta_box( 'postexcerpt', __( 'List of jobs for this client' ), 'post_excerpt_meta_box', 'alma_client', 'normal', 'core' );
}
add_action('do_meta_boxes', 'custom_post_type_boxes');

由于某种原因,缩略图元框工作正常,但摘录元框没有被绘制。我认为问题可能出在回调函数 post_excerpt_meta_box 周围,但我可能是错的。

请帮忙!我想我离修复它太近了,但无法弄清楚。

【问题讨论】:

    标签: php wordpress custom-post-type meta-boxes


    【解决方案1】:

    嗯,问题不在于post_excerpt_meta_box。出于某种原因,当我将优先级从'core' 更改为'high' 时,它起作用了。我仍然不知道为什么它像'core' 一样不可见,如果有人可以告诉我,我仍然想知道。谢谢

    生成的代码行是:

    add_meta_box( 'postexcerpt', __( 'List of jobs for this client' ), 'post_excerpt_meta_box', 'alma_client', 'normal', 'high' );
    

    【讨论】:

      猜你喜欢
      • 2015-04-10
      • 2013-10-25
      • 2012-01-02
      • 2018-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-29
      相关资源
      最近更新 更多