Home › Forums › General Issues › ACF in Theme not working properly
Is someone using ACF inside theme? Is everything working fine?
I’m trying to figure out how to initiate properly ACF plugin and my framework. When i just setup in sequence the options page add-on don’t get the values.
include acf
include acf-options-page
include framework
When I try to initiate framework on “init” hook as acf, page options title disappear and metabox doesn’t show up.
include acf
include acf-options-page
add_action('init', 'framework');
Founded! No error when insert ACF into theme, it was me, the error is only on Options Page add-on @elliot.
On acf-options-page.php line 275, there is no $page[‘menu’], instead is $page[‘title’].
Hi @edir
Sorry, I’m a bit confused about the issue / solution here.
Can you please explain the issue with a bit more detail?
Thanks
E
Forget about the topic, ACF installed into Theme is working fine.
The bug I found here was in the add-on Options Page, it doesn’t show up the title of the page. Looking into the file, at line 275 you have add_submenu_page() and get $page[‘menu’], but at the array, there is no such key.
Hi @edir
on line 114, the follow code makes sure there is a ‘menu’:
// menu
if( ! $page['menu'] )
{
$page['menu'] = $page['title'];
}
I think something else is going on here. Can you post the code you use to create your sub options pages?
Thanks
E
function test_init() {
acf_add_options_sub_page(array(
'title' => 'SEO',
'slug' => 'acf-options-module-seo',
'parent' => 'options-general.php',
'capability' => 'manage_options'
));
}
add_action('init', 'test_init');
I’m using this to load the module before ACF and their add-ons has completely loaded.
Hi @edir
I’m a bit confused about your statement:
Iām using this to load the module before ACF and their add-ons has completely loaded.
The acf_add_options_sub_page
function does not need to be run after init. It can be run in the root of functions.php
Perhaps that is the issue!
I found a bug in my framework. Now it’s working better.
But I have to check something, just tell me if this is expected. I installed ACF and Options Page as a plugin to test and this is in functions.php
theme.
acf_add_options_sub_page(array(
'title' => 'Test',
'slug' => 'acf-options-module-test',
'parent' => 'options-general.php',
'capability' => 'manage_options'
));
register_field_group(array (
'id' => 'acf_module_test_options',
'title' => 'Module Test',
'fields' => array (
array (
'key' => 'field_module_test_value',
'label' => 'Test',
'name' => 'module_test_value',
'type' => 'text',
'default_value' => 'default value',
)
),
'location' => array (
array (
array (
'param' => 'options_page',
'operator' => '==',
'value' => 'acf-options-module-test',
'order_no' => 0,
'group_no' => 0,
),
),
),
'options' => array (
'position' => 'normal',
'layout' => 'no_box',
'hide_on_screen' => array (
),
),
'menu_order' => 0,
));
function get_value() {
var_dump(get_field('module_test_value', 'option'));
}
get_value(); // don't get value
add_action('init', 'get_value'); // get value
Hi @edir
Yes, currently ACF only works after the init action.
I have found a solution to this issue and in the next version of ACF, you will be able to load get_field data from the functions.php file root.
Feel free to download the nightly release from github to test it out!
Thanks
E
@edir did that change anything? I’m asking because I’ve got the same problem and tried to update to the latest version from github. š
@elliot the docs say you need at least Options Page 1.1.0 for
if( function_exists('acf_add_options_sub_page') )
{
acf_add_options_sub_page( 'Footer' );
}
/*
* Create an advanced sub page called 'Footer' that sits under the General options menu
*/
if( function_exists('acf_add_options_sub_page') )
{
acf_add_options_sub_page(array(
'title' => 'Footer',
'parent' => 'options-general.php',
'capability' => 'manage_options'
));
}
to be effective but the plugin says there are no updates and we’re currently on 1.0.
Hi @Kevin
The options page add-on is currently at version 1.2.0
You can find updates in the wp-admin plugins page, or dashboard updates, or login to your store account and download manually
Thanks
E
Hey @elliot
Ah okay thanks.
Yep, I know but it says that there are no updates.
And the bad thing, I can’t login into the store account because it has been downloaded by a former colleague of mine and we don’t have her login data. Is it possible to get these back without purchasing the plugin again?
Best,
Kevin
Hi @Kevin
Sorry to hear about your current situation. If your business has paid for the add-on, then please email me with proof of purchase and I will be happy to help, but if she has paid for this add-on herself, I can’t grant you access to her purchases.
Cheers
E
Hey @elliot
sorry that my answer took a while but we solved that problem with buying another add-on of it. š
Best,
Kevin
The topic ‘ACF in Theme not working properly’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.