[英]Get Wordpress/ACF options on child pages
I use Wordpress with Timber (as template renderer), and Advanced Custom Fields. 我将Wordpress与Timber(用作模板渲染器)和“高级自定义字段”一起使用。 I'm struggling with some sub page options.
我正在努力处理一些子页面选项。
My problem is that I can't get the options on the right posts (my jobs) – it's only available on the job overview page. 我的问题是我无法在正确的职位(我的工作)上获得选项-仅在工作概述页面上可用。
I've created an options sub page to my custom post_type
"job", like so: 我已经为我的自定义
post_type
“工作”创建了一个选项子页面,如下所示:
if (function_exists("acf_add_options_page")) {
acf_add_options_sub_page(array(
"page_title" => "Job options",
"menu_title" => "Job options",
"menu_slug" => "job_options",
"capability" => "edit_posts",
"parent_slug" => "edit.php?post_type=job"
));
}
And I'm able to get that options on the job-overview page, like so: 我可以在工作概览页面上获得该选项,如下所示:
$context["options"] = get_fields("options");
But when I run that same command on the posts with post_type
"job", then it returns null
. 但是,当我在
post_type
“ job”的帖子上运行相同的命令时,它将返回null
。
How can I get that options to affect the posts with post_type
"job" and not the overview? 如何获得该选项以影响
post_type
“ job”而不是概述的帖子?
** EDIT ** ** 编辑 **
Okay, so I found out that somehow it had worked, since I could get SOME of the options, and I could edit them in ACF, but I couldn't add new options. 好的,所以我发现它以某种方式起作用了,因为我可以获得一些选项,并且可以在ACF中对其进行编辑,但是我无法添加新选项。 Somehow the link to "options" is broken.
到“选项”的链接以某种方式断开。 I have no idea how to fix this.
我不知道该如何解决。
This was a bug in version 5.3.2. 这是5.3.2版中的错误。 This has been fixed in version 5.3.2.1.
在版本5.3.2.1中已修复此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.