我有这个查询要插入一个新帖子:
Hyperlinks.Add(ActiveDocument.Bookmarks.Add "benchmark", benchmarkURL)
对于发布操作,仅当图库图像> 1然后将添加图库元参数,但在 $new_post_args = array(
'post_title' => empty($esc_title = wp_filter_nohtml_kses(wp_trim_words($_POST['text'], 10))) ? 'No Title' : $esc_title,
'post_content' => esc_textarea($_POST['text']),
'post_name' => sanitize_title($_POST['text']),
'post_status' => 'publish',
'post_author' => get_current_user_id(),
'post_category' => array($_POST['category']),
'comment_status' => $_POST['comments']
);
$new_post_args['meta_input']['_thumbnail_id'] = $_POST['images'][0];
if (count($_POST['images']) > 1) {
unset($_POST['images'][0]);
$new_post_args['meta_input']['gallery_images'] = implode(",", $_POST['images']);
$new_post_args['meta_input']['slider_mode'] = 'horizontal';
$new_post_args['meta_input']['slider_auto'] = 'on';
$new_post_args['meta_input']['slider_pause'] = '3000';
$new_post_args['tax_input'] = array('post_format' => 'gallery');
} else {
if ($_POST['do'] == 'update-post') {
$new_post_args['meta_input']['gallery_images'] = '';
$new_post_args['meta_input']['slider_mode'] = '';
$new_post_args['meta_input']['slider_auto'] = '';
$new_post_args['meta_input']['slider_pause'] = '';
$new_post_args['tax_input'] = array('post_format' => 0);
}
}
if ($_POST['do'] == 'update-post') {
$new_post_args['ID'] = $_POST['id'];
$new_post_id = wp_update_post($new_post_args);
} elseif ($_POST['do'] == 'share-post') {
$new_post_id = wp_insert_post($new_post_args);
}
操作中,我需要删除参数,而不是将它们添加为空update-post
,我不想在''
之后帖子已发布,我正在寻找一种方法来挂钩帖子的所有元值,如果它们是空的则不添加它们,如果可能的话,我感谢分享代码。
感谢。