【发布时间】:2015-04-21 10:23:03
【问题描述】:
使用 ACF;我正在制作一个在“draft_to_publish”和“pending_to_publish”上连接到 WP 的插件,这部分工作正常。但是当我尝试获取 ACF 生成的字段时,它们返回为空白,就好像 ACF 生成的字段尚未设置一样。
我的插件的短版如下所示:
function scheduelMailChimp( $post ) {
// get post data and preb it for mail
$post_ID = get_the_ID();
$content_post = get_post( $post_ID );
$content = $content_post->post_content;
$postTitle = get_the_title( $post_ID );
//log debuginfo til debug.log
log_me(
array(
'get field date' => get_field($field_name, $post_id, $format_value)
)
);
}
add_action( 'draft_to_publish', 'scheduelMailChimp', 10, 1 );
add_action( 'pending_to_publish', 'scheduelMailChimp', 10, 1 );
上面的代码输出为空。如果我尝试输出由 WP 而不是 ACF 生成的东西,一切都会像魅力一样。
欢迎所有和任何聪明的想法:)
【问题讨论】:
标签: wordpress advanced-custom-fields