Php Wordpress-帖子标题输入后的自定义字段
我有一个自定义字段,我想把它放在帖子标题输入之后 如何在编辑器之前更改顺序或包含自定义字段 这是我的密码:Php Wordpress-帖子标题输入后的自定义字段,php,wordpress,Php,Wordpress,我有一个自定义字段,我想把它放在帖子标题输入之后 如何在编辑器之前更改顺序或包含自定义字段 这是我的密码: function info_posts() { add_meta_box( 'intro_post', // $id 'Introducción al post', // $title 'meta_info', // $callback 'post',
function info_posts() {
add_meta_box(
'intro_post', // $id
'Introducción al post', // $title
'meta_info', // $callback
'post', // $page
'normal', // $context
'high'); // $priority
}
add_action('add_meta_boxes', 'info_posts');
function meta_info() {
global $post;
$meta = get_post_meta($post->ID, 'intro_post', true);
echo '<input type="hidden" name="info_post" value="'.wp_create_nonce(basename(__FILE__)).'" />';
echo '<table class="form-table">';
echo '<tr>
<td>
<strong>Recomendado:</strong><span class="description"> Ingresar hasta 52 palabras / 400 caracteres.</span><br/>
Total ingresado: '.str_word_count(get_post_meta($post->ID, 'intro_post', true) ).' palabras <span class="description"> (se actualiza al guardar)</span>.<br/><br/>
<textarea name="intro_post" id="intro_post" cols="95" rows="8">'.$meta.'</textarea><br/><br/>
<strong>Pequeños tips:</strong> <br/>
- Cada 25 palabras, añade uno o dos saltos de línea, ingresando el siguiente código: <input onclick="select()" value="<br/><br/>" size="7" style="border-radius:3px;border:1px solid #dcdcdc;background:#eee;color:#444"><br/>
- El texto será ubicado a la izquierda de la imagen destacada del post, procura detallar lo mejor posible el mismo.
</td>
</tr>';
echo '</table>';
}
function guardar_intro($post_id) {
if (!wp_verify_nonce($_POST['info_post'], basename(__FILE__)))
return $post_id;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return $post_id;
if ('page' == $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id))
return $post_id;
} elseif (!current_user_can('edit_post', $post_id)) {
return $post_id;
}
$old = get_post_meta($post_id, "intro_post", true);
$new = $_POST["intro_post"];
if ($new && $new != $old) {
update_post_meta($post_id, "intro_post", $new);
} elseif ('' == $new && $old) {
delete_post_meta($post_id, "intro_post", $old);
}
}
add_action('save_post', 'guardar_intro');
function info_posts(){
添加元框(
'介绍文章',//$id
“Introcción al-post”,标题//$title
“meta_info”,//$callback
“post”,第页//$
'正常',//$context
“高”);/$priority
}
添加动作(“添加元框”、“信息帖子”);
函数meta_info(){
全球$员额;
$meta=get_post_meta($post->ID,'intro_post',true);
回声';
回声';
回声'
推荐:Ingrear hasta 52帕拉布拉斯/400克拉。
总入口数:'.str_单词计数(get_post_meta($post->ID,'intro_post',true))。'palabras(se-Realiza al-guardar)。
“.$meta”。
佩克尼奥斯提示:
-卡达25帕拉布拉斯,安格拉德·奥多斯萨尔托斯德莱尼亚,安格桑多·埃尔·西奎恩特·科迪戈:
-这是一个关于邮政部门的图像的文本,是一个可能的信息来源。
';
回声';
}
函数guardar_intro($post_id){
如果(!wp_verify_nonce($_POST['info_POST'],basename(uu FILE_uu)))
返回$post_id;
if(已定义('DOING_AUTOSAVE')&&DOING_AUTOSAVE)
返回$post_id;
如果('page'=$\u POST['POST\u type'])){
如果(!当前用户可以($edit\u page',$post\u id))
返回$post_id;
}elseif(!当前用户可以($edit\u post',$post\u id)){
返回$post_id;
}
$old=get_post_meta($post_id,“intro_post”,true);
$new=$_POST[“intro_POST”];
如果($new&$new!=$old){
更新发布元($post\u id,“intro\u post”,$new);
}elseif(''=$new&$old){
删除帖子元($post\u id,“intro\u post”,$old);
}
}
添加“操作”(“保存帖子”、“guardar\u简介”);
我喜欢做什么
你能帮我吗
谢谢。我刚找到解决办法 这是: 守则:
// Move all "advanced" metaboxes above the default editor
add_action('edit_form_after_title', function() {
global $post, $wp_meta_boxes;
do_meta_boxes(get_current_screen(), 'advanced', $post);
unset($wp_meta_boxes[get_post_type($post)]['advanced']);
});
无论如何,谢谢你