这是关于Wordpress的高级自定义字段插件。
我尝试在提交时从前端表单中获取字段,并将其另存为变量以设置post_title。这篇文章似乎指向了正确的方向,但我无法让它发挥作用:http://support.advancedcustomfields.com/forums/topic/need-help-with-save_post-hook/
这是我正在使用的代码:
<?php
add_action('acf/save_post', 'retrieveEventName', 20);
function retrieveEventName( $post_id )
{
$eventName = get_field('name_of_event', $post_id);
}
?>
<?php
$args = array(
'post_title' => $eventName,
'post_type' => 'post',
'post_status' => 'draft',
'post_category' => array(9),
'comment_status' => 'closed'
);
acf_form(array(
'post_id' => 'new_post',
'form' => true,
'new_post' => $args,
'submit_value' => 'Create a new event'
));
?>
感谢您的帮助!