Home › Forums › Backend Issues (wp-admin) › Export PHP not working
Hi,
I’ve created a field for a custom post type, which worked perfectly. But then I exported the PHP and pasted it into the functions.php file, and it just doesn’t work. I’ve tried deactivating and reactivating the plugin, but I’ve had no luck. Here is the exported PHP:
if(function_exists('register_field_group')){
register_field_group(array (
'id' => 'acf_portfolio',
'title' => 'Portfolio',
'fields' => array (
array (
'key' => 'field_588e77e6e4801',
'label' => 'CMS',
'name' => 'cms',
'type' => 'text',
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'html',
'maxlength' => '',
),
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'portfolio',
'order_no' => 0,
'group_no' => 0,
),
),
),
'options' => array (
'position' => 'normal',
'layout' => 'no_box',
'hide_on_screen' => array (
),
),
'menu_order' => 0,
));
};
I tried your code and it works as expected
1) how is acf installed, as a plugin or included in the theme?
2) after you added the field group to functions.php did you move the original to the trash?
It’s installed as a plugin, and yes, I did trash the original.
Thanks!
Did you fix the problem? I’m not sure what I can suggest that you do. My guess here is that for some reason the acf function is not defined, or there can be other causes.
The next thing you should probably do is to disable other plugins on the site and see if this clears it up, there could be some type of conflict.
Unfortunately not. Good thought on disabling other plugins, but that didn’t work either. I wouldn’t expect this to be the case anyway, I’m very picky about the plugins I use and I avoid using them if possible anyway.
The only reason I can see that the field group would not appear in the admin is if for some reason your field group setup is happening before acf is included and generally the only way that can happen is if acf is installed as part of your theme.
You can try adding something like this just before to see if this is the case
if(function_exists('register_field_group')){
die('function exists');
} else {
die('function does not exists');
}
either way your php will stop executing at this point and give you a message indicating if the acf function exists or not.
Well, actually, it appears that my problem was completely unrelated. I went to try your idea, and, having closed my SFTP client for the first time since I started working on this, I had to re-download the functions.php file. It looks like none of my previous changes had successfully uploaded after all. Everything works fine now. Thanks for your help!
It’s always nice when you think you’re uploading changes and you’re really not. Been there. Makes you feel like you’re banging your head on a wall.
The topic ‘Export PHP not working’ 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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.