我正在尝试为主题中定义的每个自定义帖子类型注册ACF选项页面:
$post_types = get_post_types(
array(
\'public\' => true,
\'_builtin\' => false
),
\'objects\'
);
foreach ($post_types as $post_type) {
$post_type_slug = $post_type->name;
$options_title = $post_type->labels->name . ": Archive Options";
acf_add_options_page(array(
\'page_title\' => $options_title,
\'menu_title\' => $options_title,
\'parent_slug\' => "edit.php?post_type={$post_type_slug}",
\'menu_slug\' => "{$post_type_slug}-archive-options",
\'capability\' => \'edit_posts\',
\'redirect\' => false
));
}
这是在acf/init
吊钩(根据建议by the docs), 自定义帖子类型在WordPress上注册时init
钩(我还应该提到,这两个动作都是作为after_setup_theme
操作。)然而get_post_types()
返回空数组。这是挂钩之间的序列不匹配吗?(即,只有在acf/init
挂钩)