Is anything being output there? For example, if you just put some text after where the options are supposed to be shown, does that text appear on the page?
I would suggest that you look at the Tab field type in ACF. It seems to work similar to how you want your fields to work. If you follow that as an example you may only need one additional field type.
I don’t know anything about IDXpress plugin, but your problem would indicate that the template that’s showing the listings must be using a different header file than the one you put the code in.
How to you plan on associateing each select value with an image. The select field itself doesn’t have the images as values, or does it?
This is a very old topic, just in case anyone happens upon this because they’re wondering, since then this has been built into ACF.
I just found this, maybe you should give the author of this plugin some input https://github.com/lukechapman/acf-inline-wysiwyg
I don’t see anything wrong with the code. There are two things that I can think of that would cause this. Either the field group is not being edited on the home page or your template file is not being called. What are the location rules for the page?
The user field returns an array that looks like this:
Array
(
[ID] => 6
[user_firstname] => John
[user_lastname] => Doe
[nickname] => johndoe
[user_nicename] => johndoe
[display_name] => John Doe
[user_email] => [email protected]
[user_url] =>
[user_registered] => 2016-07-03 12:23:56
[user_description] =>
[user_avatar] =>
)
This was generated by adding the following to a template where I want to use the information
echo '<pre>'; print_r(get_field('user_field')); echo '</pre>';
Hope that helps
Well, if you’re using ACF pro, there is a hook you can use to remove the field on the back end, but it’s not something that’s documented. I have a plugin that lets you set removal of field by user type. You could use the hook I’m using to remove specific field if is_admin() returns true.
You may need to play with this a bit to get it to work, the ACF hook is acf/get_fields
, like I said, it’s not documented.
You can find it called on line 740 of /api/api-field.php. You need to set the priority > 10 to run after the internal ACF filter.
add_filter('acf/get_fields', 'your_function_name', 20, 2);
function your_function_name($fields, $parent) {
// remove the fields you don't want
return $fields;
}
It’s just a starting point. $fields can be a nested array of fields => sub_fields.
If you want you can see how I do this for user types on line 89 of this file https://github.com/Hube2/acf-user-role-field-setting/blob/master/acf-user-role-field-setting.php
do you want to remove this field for everyone, or just certain types of users?
There is nothing built into ACF that will let you hide a field. You will need to add custom CSS to the admin head https://www.advancedcustomfields.com/resources/acf_head-input/
A taxonomy field returns either 1 term object or an array of term objects depending on what you set the field for. You need to access the properties of the object.
The documentation for the taxonomy field is here https://www.advancedcustomfields.com/resources/taxonomy/
It’s just that I don’t have any experience with trying to upload files into the root of the site. I’m not sure if it’s even possible to be honest, it could be that this is being prevented by WP somehow. You might also want to look on other forums for a solutions because this is not really specific to ACF. The only part of this that’s specific to ACF is adding the upload_dir
filter on a specific field.
I’m not sure if this is going to be any help to you or not because I don’t know exactly how to accomplish what you want to do.
If you want to see your additional fields refreshed when an image is uploaded and chosen, you’ll need to do some of your own AJAX to get it done. I know that image uploads are handled by WP and not by ACF. After the upload an event is triggered that causes ACF to get the data related to the image and populate the image field.
Your best bet is to add an event action when this happens, do your own AJAX request to get the additional information that you are looking for and then populate the additional fields. This is where my knowledge is lacking, but I can give you some examples of triggering AJAX requests when ACF fields change and populating other fields based on the results of the requests. There just isn’t anything specifically related to doing this for an image field so you’ll need to do some investigation to get it done and it will likely take a bit of trial and error. Anyway, you can find my examples of dynamically loading ACF fields using AJAX here https://github.com/Hube2/acf-dynamic-ajax-select-example
Try installing this plugin https://wordpress.org/plugins/wp-max-submit-protect/, attempt to save your new fields and see if you get a warning message about exceeding max_input_vars.
How you display the value depends on the value returned. A taxonomy field can return either the term ID, or the term object, or it can return an array of term IDs or term objects depending on the field’s settings. An image field can return one of three different value types. You’ll need to read the documentation on each of the different field types for examples of how to display the values.
This was almost right
<?php
$queried_object = get_queried_object();
$taxonomy = $queried_object->taxonomy;
$term_id = $queried_object->term_id;
$value = get_field( 'test_field', $taxonomy.'_'.$term_id);
if( $value ) {
echo $value;
} else {
echo 'empty';
}
?>
I’m a little confused about where these fields are located. Are they located on a post or on a term? What are the location rules?
This is just a guess, but it sounds like a problem with the wp cache. Try cleaning the cache for the post after you add the new rows and before you try to count them again. https://codex.wordpress.org/Function_Reference/clean_post_cache
<?php clean_post_cache( $id ) ?>
I have 2 examples here https://github.com/Hube2/acf-dynamic-ajax-select-example that if you use some of the ideas from both you could do this. One of the examples is how to populate a select field base on another select field https://github.com/Hube2/acf-dynamic-ajax-select-example/tree/master/dynamic-select-example and the other is how to populate fields based on a selection in a relationship field https://github.com/Hube2/acf-dynamic-ajax-select-example/tree/master/dynamic-fields-on-relationship
A post object field and a relationship field are similar, although you may need to do some work to get that working. You can use either example for the AJAX portion, the main difference is that you’re going to be getting values from the repeater in the “Location” post to populate the second select field. Or you can go with just the 2 select field option and populate the fist field the same way that the example shows and the second field from the repeater.
This is actually another good example that I will put together if I have time. “Populate a select field from a repeater based on the selection of a post object field”
There are few ways you can do this, the first is not really optimized, but it will shorten the work.
$flex = get_field('flexible_content_field');
That will put the entire contents of the flex field into an array and then you can get the row by targeting the array element you need
// the array elements start with 0 instead of 1
// so row 2 will be element 1 of the array
$text = $flex[1]['text_field'];
You will need to output the contents of the array to be 100% certain what it contains, and it will give you a better idea of what to do with it.
echo '<pre>'; print_r($flex); echo '</pre>';
While not 100% optimized, because you are getting all of the rows at once, the values are cached so additional calls to get the entire flex content should not generate additional queries to the DB.
The second way is to only get what you want using get_post_meta()
For example, a text field on the second row will have a meta key that looks something like this repeater_field_name_2_text_field_name
. The meta key repeater_field_name
will return a array of the layouts for each row.
Like I said, more complicated, but you only get what you need.
It depends on what type of search you are doing really. If you are doing a keyword search you could probably use something as simple as Search Everything https://wordpress.org/plugins/search-everything/
The thing is that you need to tell it where to search and the content needs to be part of the post you want to return as a result, usually in some hidden post meta field. WP and ACF have some limitations, the best that we can do is work around them.
Here’s an old topic that the developer commented on https://support.advancedcustomfields.com/forums/topic/order-custom-post-by-sub-custom-field-values/ which basically says the same thing but points out that you could do this if you only looked at the first row of the repeater when sorting.
acf_get_setting('google_api_key');
should return the value
Using standard WP methods you would need to do a query for every post that might have a review and then loop through the repeater fields on every post to collect them all. If there are a lot this would more than likely time out your site, although you could probably incorporate some type of object or fragment caching. If you do a search you’ll find plenty of information on it.
You could use #wpdb and query the wp_meta table directly to speed things up https://codex.wordpress.org/Class_Reference/wpdb, but because you’re using repeater fields the query would be quite complicated. If you’re thinking about this you should probably spend some time digging around in the database to see how ACF stores the values of a repeater.
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.