Is this exactly where and the order that the code appears on you page? or are you just leaving out the code in between. https://www.advancedcustomfields.com/resources/acf_form/
acf_form_head();
must be placed before any HTML is generated. Generally before get_header();
in your template or in your header.php file something like this
<?php
/**
* The template for displaying the header
*
* Displays all of the head element and everything up until the "site-content" div.
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0
*/
acf_form_head();
?><!DOCTYPE html>
It may be saved in the database, but is it save to a post_id with a post type of “dog”?
There isn’t any tool that I am aware of that will let you export and import values from/to the wp_options table. Anything like this you’d probably be looking at building yourself.
Keep in mind that for every option name you have that there is another value in the table that matches it with the field_key value associated with the field. Option names created by ACF are "options_{$your_field_name}"
and the matching field key is stored under "_options_{$your_field_name}"
. Repeaters or anything with sub fields gets a lot more complicated.’
When dealing with options, or any value that may or may not be present, for example if these options are part of a theme and the option values are needed when the theme is installed, the best choice, and best coding practice, is to have a default value for all fields, use the default value in your code and assume that the value may not exist. For example
$value = get_field('my_option_field', 'options');
if (!$value) {
$value = 'my default value'
}
This can also be written something like this
if (($value = get_field('my_option_field')) === NULL) {
$value = 'my default value';
}
Yes, this is a little more work but much less work than building and export/import tool for these values.
Please submit these bug reports here https://support.advancedcustomfields.com/new-ticket/
Then there could be a bug for fields in PHP. I did not look closely at the code, sorry, I was going by what I happen to know that array index is used for, now that I’m looking at it closer I might be completely wrong.
It appears that this is entirely new code added for recent issue brought up with post preview.
This isn’t part of what you asked, but You can use -1
for posts_per_page
to tell WP to get all of the posts
<code>posts_per_page</code> => -1,
But as far as your real question goes, no. WP_Query is not capable of doing joins to other posts through a custom field. For something like this you would need to write your own SQL query and use https://codex.wordpress.org/Class_Reference/wpdb and then write your own code to loop over and display the results.
You need to add an event to a trigger on the field. For the standard WP category box you need to add an action when something there is changed. For an ACF taxonomy field you need to add an action to the change event of that field. Take a look at the jQuery docs for .on()
, .bind()
, .click()
, etc. There are probably dozens of ways this can be done but really nothing to do with ACF.
As far as making a specific tab active, all you really need to do is trigger the click event for that tab in the action you add to the other element. For example, if I have an acf field group with the group key of group_586cf71a7742c
and a tab with a field key of field_586d38c5329b5
$('#acf-group_586cf71a7742c .acf-tab-wrap [data-key="field_586d38c5329b5"]').trigger('click');
$field['_name']
holds the actual name of the field. In the case of repeater and other sub fields $field['name']
holds a modified field name that is equal to the meta_key value that the field will be stored as. This is not a bug.
Other than the solution I gave over at https://support.advancedcustomfields.com/forums/topic/how-to-make-field-taxnonmy-for-parent-category-other-field-for-child-category/
This topic might help you for taxonomy fields https://support.advancedcustomfields.com/forums/topic/send-additional-field-for-ajax-update-event-on-selecttaxonomy/
I don’t know of the OP found a solution. This question was asked a long time ago.
I would use select fields and not taxonomy fields. For the first field I would dynamically generate the values of the “parent” category form the information here https://www.advancedcustomfields.com/resources/dynamically-populate-a-select-fields-choices/
For the child category I would use ajax to populate the select field. I have created an example of doing this here https://github.com/Hube2/acf-dynamic-ajax-select-example/tree/master/dynamic-select-example. This example uses posts in a post type, but the principle is the same.
You would also need to create an acf/save_post filter https://www.advancedcustomfields.com/resources/acf-save_post/ if you want to update the post categories https://codex.wordpress.org/Function_Reference/wp_set_post_terms since you wouldn’t be using a taxonomy field that would do this automatically.
To be completely honest, I’m not sure about the answers to your questions. There are several function in ACF that are used internally and not documented on this site. acf_get_field() is one of those. These functions can take arguments.
acf_get_field_group() is another of these functions.
and another is acf_get_fields($group_key), which will return an array of all of the fields in a groups, including sub fields, and I’m assuming this would include clone fields.
Like I said in my original answer, I don’t know exactly how to do what you want to do, but somehow ACF must know do something to tell it how the clone field is related to the parent group.
The only suggestion I can give you is something I’ve seen on these forums for other conflicts. First, report the conflict both here https://support.advancedcustomfields.com/new-ticket/ and with the other plugin.
The next step for a temporary solution it to dequeue one of the datepickers or othewise prevent it from loading. https://codex.wordpress.org/Function_Reference/wp_dequeue_script. If the datepicker in vc is using the same handle and it loads first then this is why it is loaded instead of ACF’s date picker.
The reason for my question was, that instead of trying to get ancestors you might try walking backwards. The parent of the field is set, is the parent of the parent field set in that field? Is the parent of that field set? etc
but I did use the wrong function in my example
$parent = acf_get_field($field['parent'], $post_id);
echo '<pre>'; print_r($parent); echo '</pre>';
Sorry if there is some confusion. The developer is working hard on ACF and does not get here as often as he’d like. There are people like myself that do our best to answer question here, but we’re really only other ACF users. The regular support, contacted through the ticket system, I believe keeps a list of feature requests, although I’m not sure. But there is a higher chance that E will see them buy submitting a new support ticket than posting them here, although this could change. E has hired more help and who knows, he might finally find some spare time 😛
I’ve also tried this with a post object field in a repeater, still no problem with anything resetting or changing when I edit a related post. Again, if this were me, I would start by deactivating plugins and trying an unmodified basic theme to find where the conflict is. In order to help I would need to be able to consistently recreate the issue, at the moment I cannot.
More than likely the theme is including it’s own version, or a different version of the data/time and/or time picker which in interfering with the operation of the ACF version. I don’t know anything about the theme. You can try submitting a support ticket on this issue https://support.advancedcustomfields.com/new-ticket/ and you should probably also contact your support for the theme.
If your not seeing time setting in the field disable other plugins and see if you can figure out where the conflict is. The dat/time and time fields are working correctly for me.
Have you disabled other plugins? There could be something causing a conflict with ACF.
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.
Is something like this possible? Yes. Is it something that I could explain? Not in much detail. You’d basically need to dynamically generate a field group for your new post type based on the values in the first post type and you’d also need to dynamically load values for the field in the field group.
At this point my suggestion is going to be to submit a new support ticket https://support.advancedcustomfields.com/new-ticket/
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.
The way to counter it is to figure out what _usermeta meta_key it’s stored under, figure out how that value is stored and then update that value every time a user saves a post. WP does not provide any way to control this setting. You might, want to look into filters that WP runs when updating user meta values and see if there’s any way of altering the value before it’s saved.
So, just adding two fields to every post is pretty simple. You just create a field group with the two fields for post type == post.
But I have a feeling that what you’re looking for is adding these fields to the front end where the posts are shown. If this is what you want, this does not get done automatically. You’ve got to edit the template code for the front end to do the adding.
@kaitlyn’s response is a good one. Tires should be the only post type. Brand, Season and Type should all be custom taxonomies associated with the tire post type. This will allow you to have pages associated with each of the taxonomies. For example, a list of all “Winter” tires, or a list of all “Good Year” tires or a list of all “Radial” tires, etc… Using custom taxonomies for these “attributes” you could even construct a custom search filter that could allow visitors to filter their selection by more than one of them, for example “Good Year Winter” Tires.
I don’t see a call to wp_reset_postdata()
in your code. This will cause unpredictable errors. https://www.advancedcustomfields.com/resources/relationship/
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.