我到处找了找,但我不能确定这个问题的答案。我试图将自定义字段的内容用作post\\U数据,并在创建或更新帖子时将其保存到数据库中。我需要这样做,以便使用插件高级自定义字段实现前端发布解决方案。
我想我需要这样的东西:
function tsv_content_save_pre( $post_id ){
global $post;
$tsvpost = get_post($post_id);
$tsvifempty = $tsvpost->post_content; //The "real" post_content
$tsvcontent = get_field(\'article_content\'); //The custom content
if ($tsvifempty == NULL) { //Check if the "real" post content has anything in it first.
$tsvargs = array(\'post_content\' => $tsvcontent);
wp_update_post ($tsvargs);
}
}
add_filter(\'content_save_pre\' , \'tsv_content_save_pre\' );
但我被困在那里了。我不是插件开发人员,所以过滤器之类的东西对我来说很难导航。有人能帮我指出正确的方向吗?提前谢谢。