Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在WordPress中为自定义帖子添加第二个标题?_Php_Wordpress - Fatal编程技术网

Php 在WordPress中为自定义帖子添加第二个标题?

Php 在WordPress中为自定义帖子添加第二个标题?,php,wordpress,Php,Wordpress,目前我正在学习自定义帖子类型,所以我不确定如何从这里开始 我为事件创建了一个自定义帖子,它与普通帖子几乎相同,只是措辞略有不同。但我之所以做一个,是因为我想在最初的标题之后再加上一个标题 为了让这对用户来说尽可能简单,我希望这个文本字段正好位于主编辑器上方的第一个文本字段下方。只是想知道我该怎么在这里加上它 register_post_type('events', array( 'label' => 'Events', 'description'

目前我正在学习自定义帖子类型,所以我不确定如何从这里开始

我为事件创建了一个自定义帖子,它与普通帖子几乎相同,只是措辞略有不同。但我之所以做一个,是因为我想在最初的标题之后再加上一个标题

为了让这对用户来说尽可能简单,我希望这个文本字段正好位于主编辑器上方的第一个文本字段下方。只是想知道我该怎么在这里加上它

register_post_type('events',
    array(  
        'label' => 'Events',
        'description' => 'Events section',
        'public' => true,'show_ui' => true,
        'show_in_menu' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'rewrite' => array('slug' => ''),
        'query_var' => true,
        'exclude_from_search' => false,
        'supports' => array('title','editor','thumbnail','author','page-attributes',),
        'taxonomies' => array('category',),
        'labels' => array (
            'name' => 'Events',
            'singular_name' => 'Event',
            'menu_name' => 'Events',
            'add_new' => 'Add Event',
            'add_new_item' => 'Add New Event',
            'edit' => 'Edit',
            'edit_item' => 'Edit Event',
            'new_item' => 'New Event',
            'view' => 'View Event',
            'view_item' => 'View Event',
            'search_items' => 'Search Events',
            'not_found' => 'No Events Found',
            'not_found_in_trash' => 'No Events Found in Trash',
            'parent' => 'Parent Event',
        ),
    ) 
);

'title'
似乎是标准的,所以我想知道是否可以创建另一个实例?

您可以通过更改自定义文章类型的编辑器布局来实现。本网站将向您展示如何做到这一点。您可以在编辑器中为副标题行创建一个框

更新:有一个类似于普通元框的
save\u post


不,只能有一个标题

您必须创建一个记录第二个标题的值

问题是它不能放在标题和内容框之间

我建议使用插件。它已经得到了积极的开发,对于生成各种CF非常方便


我就是这样做的,点击图片放大:

配置一个高级自定义字段


结果显示自定义Post类型屏幕


使用jQuery帮助移动字段
add_action('admin_head','so_13726274_move_field');
函数so_13726274_move_field()
{
?>
jQuery(文档).ready(函数($)
{     
$(“#acf text”).prependTo(“#postdivrich”);
$(#acf-field_50baa73272855').css('width','100%);
});
add_action( 'admin_head', 'so_13726274_move_field' );

function so_13726274_move_field()
{
    ?>
    <script type="text/javascript">
        jQuery(document).ready(function($)
        {     
            $('#acf-text').prependTo('#postdivrich');
            $('#acf-field_50baa73272855').css('width','100%');
        });
    </script>
    <?php
}