【发布时间】:2015-09-12 09:06:09
【问题描述】:
这是我的代码:
function my_post_title_updater( $post_id ) {
$my_post = array();
$my_post['ID'] = $post_id;
$brand = get_field('brand');
$asset = get_field('asset');
$language = get_field('language');
$countryfield = get_field_object('country');
$countryvalue = get_field('country');
$country = $countryfield['choices'][ $countryvalue ];
if ( get_post_type() == 'project' ) {
$my_post['post_title'] = $brand . ' ' . $asset . ' ' . $country . ' ' . $language ;
}
wp_update_post( $my_post );
}
add_action('acf/save_post', 'my_post_title_updater', 20);
在发布 Wordpress 帖子时,此功能应该基于一些高级自定义字段创建标题。目前它所做的是获取“品牌”、“资产”和“语言”,而不是“国家”。但是,点击帖子的“更新”后,它会在标题中显示国家/地区。
任何帮助将不胜感激。
【问题讨论】:
-
它应该做什么?
-
我很确定我在帖子中解释过,不是吗?哪一部分不清楚?
-
您是否检查过激活 WP_DEBUG 时是否出现故障?
-
为您的回复干杯! WP_DEBUG 设置为 true,据我所知,它并没有引发失败。然而,它的最后期限很紧,所以我不得不找到一个解决方法。
标签: php wordpress advanced-custom-fields