Ah perfect. Didn’t expect it would be so easy 🙂 Thank you.
Well, @John, you were dead right. I looped through and updated the field keys and that did the trick 🙂 Cheers for all your help 🙂
The json data that I am importing is exported from a site using Drupal6. In the orginial code Drupal considered this to be a taxonomy but in WordPress it is a simple text field as are the other two meta fields. The WordPress site uses the wp API (v2) to display the post data on the front end for reasons that are a bit complicated to explain 😉
I take your point that the field key is required though. So I take it I should retrieve the field keys of each of the fields in question and also update them in my import function?
update_post_meta( $post_id, _{$field_name}, $field_key )
Thanks for your response @John_Huebner, I also tried this with
update_post_meta()
and didn’t have any success in displaying the data. That said, even without the update functions the post meta is inserted into the database. It is only the API that isn’t being updated. I’ll remember that when using update_field()
though.
Cheers
Hi @airesvsg,
I’m having a problem displaying the acf fields in the api from dynamically created posts using wp_insert_post()
(see WPSE question here ) I’m guessing I need to make the WP API writable to the ACF fields. They do display once I click the Publish button though but there are too many posts to do this.
Cheers
Hi Eliot,
My problem was that I was using the [value] in the template -which was returned from the key. Problem solved by using:
$field = get_field_object('selling_points');
$points = get_field('selling_points');
foreach ( $points as $point ){
$label = $field['choices'][ $point];
echo '<li class="bullet-item">'.$label.'</li>';
}
}
(My thanks to Micheal on your support staff)
Hi @elliot,
Ah, I haven’t included the plugin (as a plugin) in the theme so I don’t have it as a menu item. I am fairly comfortable with php-my-admin though so I’m just going to go and see what’s in there.
I’ll keep you posted.
Thanks,
Kirsten
Update: I think I’ve found the problem. I went through php-my-admin and queried post_type LIKE %acf% and found several entries. I must have imported them as a custom post type when I migrated from local to staging. I presume I can just delete them? Please confirm.
Hi @elliot,
Yes this is the connection with WPML both “Manchettes” and “FAQ” were created upon translating “Headlines” and “FAQ”. I’m not quite sure what you mean about them being registered in the DB. I did look for the fields in the DB hoping to simply delete them but I couldn’t find them. I assume they are in postmeta and did a search for the field id but only found one entry. I think we’re on the right track though. I’ll also have a look at the WPML tables. Can you tell me specifically what to look for as I’m guessing “Headlines” is buried in an array.
Hi @elliot,
It turns out that its another plugin that is putting jquery migrate in there. This is turning out to be a bit more complicated than I anticipated.
I think I am just going to focus my energy on cacheing.
To answer your question the add-ons are fairly recent. I think I bought them in October. Probably not old enough to warrant jquery migrate. I have included them in the theme so I’m a bit hesitant to update them even though I noticed there is an update available.
Thanks so much for your help.
Ah sorry, I meant the acf “add-ons” which I put in a folder thus named:
include_once('add-ons/acf-repeater/acf-repeater.php');
include_once('add-ons/acf-gallery/acf-gallery.php');
Thanks.
Hi @elliot,
Well that explains why I couldn’t find it but it seems to go away when I remove the add-ons folder. Any idea why the above bit of code doesn’t work to put jquery in the footer?
Here is what I’m basing my findings on:
Hi @elliot,
Ideally a function to override it’s position in the header so that the plugin would be intact for any potential updates (unless, of course, you were considering changing it in an update.)
I tried modifying the wp_register_scripts like so :
$scripts = array();
$scripts[] = array(
'handle' => 'acf-field-group',
'src' => $this->settings['dir'] . 'js/field-group.min.js',
'deps' => array('jquery'),
'in_footer' => true
);
$scripts[] = array(
'handle' => 'acf-input',
'src' => $this->settings['dir'] . 'js/input.min.js',
'deps' => array('jquery'),
'in_footer' => true
);
$scripts[] = array(
'handle' => 'acf-datepicker',
'src' => $this->settings['dir'] . 'core/fields/date_picker/jquery.ui.datepicker.js',
'deps' => array('jquery', 'acf-input'),
'in_footer' => true
);
foreach( $scripts as $script )
{
wp_register_script( $script['handle'], $script['src'], $script['deps'], $this->settings['version'], $script['in_footer']);
}
but I can’t find where they are enqueued. And it seems I’m looking in the wrong place as there is no jquery migrate here.
Hi @elliot,
It’s for the front end. I’m not too worried about the back end. But it makes a significant difference if I remove the add-ons folder containing acf-gallery and acf-repeater which add jquery and jquery migrate in the head tag.
Sorry Elliot,
I did miss that. The correct function in case anyone asks is icl_object_id()
Thanks again,
Kirsten
Hi Elliot,
The wpml_get_current_post_id(); gave me a fatal error but I’ve contacted them as well. In the meantime I sorted it out by hardcoding the values like so:
location' => array (
array (
array (
'param' => 'page',
'operator' => '==',
'value' => '8',
'order_no' => 0,
'group_no' => 0,
),
),
array (
array (
'param' => 'page',
'operator' => '==',
'value' => '153',
'order_no' => 0,
'group_no' => 0,
),
),
(I was missing an array in the first example) Anyhow I’ll let you know which function worked when I get a response from them.
Cheers for the quick response,
Kirsten
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.