Wordpress wp_编辑器未显示特色缩略图图像
我正在开发一些可以在前端创建新帖子的主题。我的问题是,当“添加媒体”上传了照片后,一切都很好,除了当我为该帖子设置“设置特色图片”时,该帖子在发布时不会显示在“缩略图”上 这是wp_编辑器代码设置:Wordpress wp_编辑器未显示特色缩略图图像,wordpress,wordpress-theming,Wordpress,Wordpress Theming,我正在开发一些可以在前端创建新帖子的主题。我的问题是,当“添加媒体”上传了照片后,一切都很好,除了当我为该帖子设置“设置特色图片”时,该帖子在发布时不会显示在“缩略图”上 这是wp_编辑器代码设置: <?php $setupev = array( 'media_buttons'=>1, 'textarea_name'=>'post_ne', 'tinymce' => true ); wp_editor('cont
<?php
$setupev = array(
'media_buttons'=>1,
'textarea_name'=>'post_ne',
'tinymce' => true );
wp_editor('content here', 'create_nepost', $setupev);
?>
是否有一些代码可添加以获取附件缩略图?您需要使用
设置发布缩略图()
函数。此函数需要两件事,一是$post\u id
,它是您提供给wp\u insert\u post()
的id;二是$attach\u id
,它是附件的id
set_post_缩略图($post_id,$attach_id)代码>
您已经有了$post\u id
,可以找到$attach\u id
$attachment=array(
)代码>
$attach\u id=wp\u insert\u attachment($attachment,$file,$post\u id)代码>
require_once(ABSPATH.'wp admin/includes/image.php')代码>
$attach\u data=wp\u生成附件元数据($attach\u id,$file)代码>
wp\u更新\u附件\u元数据($attach\u id,$attach\u data)代码>您需要使用set\u post\u缩略图()
函数。此函数需要两件事,一是$post\u id
,它是您提供给wp\u insert\u post()
的id;二是$attach\u id
,它是附件的id
set_post_缩略图($post_id,$attach_id)代码>
您已经有了$post\u id
,可以找到$attach\u id
$attachment=array(
)代码>
$attach\u id=wp\u insert\u attachment($attachment,$file,$post\u id)代码>
require_once(ABSPATH.'wp admin/includes/image.php')代码>
$attach\u data=wp\u生成附件元数据($attach\u id,$file)代码>
wp\u更新\u附件\u元数据($attach\u id,$attach\u data)代码>谢谢。。那么,我必须从wp_编辑器(添加媒体)中找到attachmentID吗?要这样做,$attach\u id=wp\u insert\u attachment('','')
那么获取附件的方法就是使用$wp\u filetype['type']
?嗯,我试试。谢谢。。那么,我必须从wp_编辑器(添加媒体)中找到attachmentID吗?要这样做,$attach\u id=wp\u insert\u attachment('','')
那么获取附件的方法就是使用$wp\u filetype['type']
?嗯,我试试看
$the_contnt = $_POST['post_ne'];
$new_post = array(
'post_title' => $get_title,
'post_content' => $the_contnt,
'post_date' => date('YmdHis'),
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array(8,5)
);
wp_insert_post( $new_post );
'post_mime_type' => $wp_filetype['type'],
'post_title' => sanitize_file_name($filename),
'post_content' => '',
'post_status' => 'inherit'`