
Hi @nickfmc
Just wanted to let you know I have pushed an update to github containing a filter for the user field $args.
You can hook in and modify them like so:
<?php
function my_acf_user_query( $args, $field, $post_id ) {
// http://codex.wordpress.org/Function_Reference/get_users
$args['orderby'] = 'nicename';
return $args;
}
add_filter('acf/fields/user/query/name=CUSTOM_FIELD_NAME', 'my_acf_user_query', 10, 3 );
?>
You can also remove the /name=CUSTOM_FIELD_NAME for this to run on all user fields.
Thanks
E

This is a great question, and one which can be achieved by reading about querying posts via a sub field value here:
http://www.advancedcustomfields.com/resources/how-to/how-to-query-posts-filtered-by-custom-field-values/#example-5
I have done some copy / paste and put together a template for you. Just replace {$repeater_field_name} with your repeater field name, and {$sub_field_name} with your sub field name, and it should work! Fingers crossed:
<?php
// custom filter to replace '=' with 'LIKE'
function my_posts_where( $where )
{
$where = str_replace("meta_key = '{$repeater_field_name}_%_{$sub_field_name}'", "meta_key LIKE '{$repeater_field_name}_%_{$sub_field_name}'", $where);
return $where;
}
add_filter('posts_where', 'my_posts_where');
// args
$args = array(
'post_type' => 'whose-posts-we-want-to-display',
'meta_query' => array(
array(
'key' => '{$repeater_field_name}_%_{$sub_field_name}',
'value' => '"' . get_the_ID() . '"',
'compare' => 'LIKE'
)
)
);
// get results
$the_query = new WP_Query( $args );
// The Loop
?>
<?php if( $the_query->have_posts() ): ?>
<ul>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>
Thanks
E
Thanks for your quick suggestion, however I tried for quite a while now but can’t seem to find where to add that rule.
I’m using your code from the documentation:
<script type="text/javascript">
(function($) {
/*
* render_map
*
* This function will render a Google Map onto the selected jQuery element
*
* @type function
* @date 8/11/2013
* @since 4.3.0
*
* @param $el (jQuery element)
* @return n/a
*/
function render_map( $el ) {
// var
var $markers = $el.find('.marker');
// vars
var args = {
zoom : 16,
center : new google.maps.LatLng(0, 0),
mapTypeId : google.maps.MapTypeId.ROADMAP
};
// create map
var map = new google.maps.Map( $el[0], args);
// add a markers reference
map.markers = [];
// add markers
$markers.each(function(){
add_marker( $(this), map );
});
// center map
center_map( map );
}
/*
* add_marker
*
* This function will add a marker to the selected Google Map
*
* @type function
* @date 8/11/2013
* @since 4.3.0
*
* @param $marker (jQuery element)
* @param map (Google Map object)
* @return n/a
*/
function add_marker( $marker, map ) {
// var
var latlng = new google.maps.LatLng( $marker.attr('data-lat'), $marker.attr('data-lng') );
// create marker
var marker = new google.maps.Marker({
position : latlng,
map : map
});
// add to array
map.markers.push( marker );
// if marker contains HTML, add it to an infoWindow
if( $marker.html() )
{
// create info window
var infowindow = new google.maps.InfoWindow({
content : $marker.html()
});
// show info window when marker is clicked
google.maps.event.addListener(marker, 'click', function() {
infowindow.open( map, marker );
});
}
}
/*
* center_map
*
* This function will center the map, showing all markers attached to this map
*
* @type function
* @date 8/11/2013
* @since 4.3.0
*
* @param map (Google Map object)
* @return n/a
*/
function center_map( map ) {
// vars
var bounds = new google.maps.LatLngBounds();
// loop through all markers and create bounds
$.each( map.markers, function( i, marker ){
var latlng = new google.maps.LatLng( marker.position.lat(), marker.position.lng() );
bounds.extend( latlng );
});
// only 1 marker?
if( map.markers.length == 1 )
{
// set center of map
map.setCenter( bounds.getCenter() );
map.setZoom( 14 );
}
else
{
// fit to bounds
map.fitBounds( bounds );
}
}
/*
* document ready
*
* This function will render each map when the document is ready (page has loaded)
*
* @type function
* @date 8/11/2013
* @since 5.0.0
*
* @param n/a
* @return n/a
*/
$(document).ready(function(){
$('.acf-map').each(function(){
render_map( $(this) );
});
});
})(jQuery);
</script>
Thanks guys. I’ve conjured up this, which in my mind should work:
function same_youtube_options_controls_acf($content) {
$content = get_sub_field('iframe_url');
return str_replace("rel=0&", "rel0&&autohide=1&showinfo=0&controls=1&", $content);
}
add_filter('acf/load_field/name=iframe_url', 'same_youtube_options_controls_acf');
However, the iframe_url just disappears.
Sorry to be a pain.
Hi Elliot,
Thank you for your reply. Your solution worked, thanks!
But I really need the extra ‘status’ parameter. It’s an another custom field where I can mark the item as sold/reserved/for sale.
How can I combine this with the meta_query?
Thanks,
Edwin
Hello,
The generated html is as follows:
<!-- Start Flexslider -->
<div class="flexslider">
<ul class="slides">
<li data-thumb="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_172_orig_copy-150x150.jpg">
<img src="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_172_orig_copy.jpg" alt="" />
</li>
<li data-thumb="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_CLS_orig_copy-150x150.jpg">
<img src="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_CLS_orig_copy.jpg" alt="" />
</li>
<li data-thumb="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_170_orig_copy-150x150.jpg">
<img src="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_170_orig_copy.jpg" alt="" />
</li>
<li data-thumb="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_30_orig_copy-150x150.jpg">
<img src="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_30_orig_copy.jpg" alt="" />
</li>
</ul>
</div>
<!-- End Flexslider -->
Which is odd because it looks as if the images and thumbs should match up.
I was using a Flexslider example and creating the thumbs in this line (from previous posted code)
<li data-thumb="<?php echo $image['sizes']['thumbnail']; ?>">
The Flexslider suggested code is as follows:
JS
// Can also be used with $(document).ready()
$(window).load(function() {
$('.flexslider').flexslider({
animation: "slide",
controlNav: "thumbnails"
});
});
HTML
<!-- Place somewhere in the <body> of your page -->
<div class="flexslider">
<ul class="slides">
<li data-thumb="slide1-thumb.jpg">
<img src="slide1.jpg" />
</li>
<li data-thumb="slide2-thumb.jpg">
<img src="slide2.jpg" />
</li>
<li data-thumb="slide3-thumb.jpg">
<img src="slide3.jpg" />
</li>
<li data-thumb="slide4-thumb.jpg">
<img src="slide4.jpg" />
</li>
</ul>
</div>
I’ve kinda mashed these together after watching your vimeo video example.
When I change the order of the thumbnails via the Gallery Field in the WP Post screen, should it (in theory) update the order of the thumbnails and full size images? (I understand it’s mostly likely me, so when I say ‘in theory’ I mean no offence!)
my last post got me wondering why there wasn’t an auto_incrementing field. that seemed highly unusual; in fact, according to this…wp_postmeta should not have any 0’s in the meta_id field since it is supposed to be an auto-incrementing field. i lost my indexes somewhere.
https://codex.wordpress.org/Database_Description#Table:_wp_postmeta
and, adding the indexes back fixes it! here are the queries i used if it helps anyone that somehow lost their indexes as well.
alter table wp_postmeta change column meta_id id integer unsigned, add column meta_id integer unsigned primary key auto_increment first;
update wp_postmeta set meta_id = meta_id + 9000; -- more than the number of rows in the table
update wp_postmeta set meta_id = id where id <> 0;
alter table wp_postmeta drop column id;
alter table wp_postmeta add index (meta_key), add index (post_id);
in narrowing it down, i can recreate using just this as my acf.php:
<?php
if(function_exists("register_field_group"))
{
register_field_group(array (
'id' => 'acf_experience-post-fields',
'title' => 'Experience Post Fields',
'fields' => array (
array (
'key' => 'field_52bc856a5d6b9',
'label' => 'Is Auction',
'name' => 'is_auction',
'type' => 'true_false',
'instructions' => '',
'message' => '',
'default_value' => 0,
)),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'experience',
'order_no' => 0,
'group_no' => 0,
),
),
),
'options' => array (
'position' => 'normal',
'layout' => 'no_box',
'hide_on_screen' => array (
),
),
'menu_order' => 0,
));
}

Hi @advancedcustomfields@swell.nl
The relation should be OR to allow for any of the meta_query’s to match. I can’t explain why ALL the art appears.
Firstly, can you change:
$arrays[$i] = array(
to:
$arrays[] = array(
I’m not sure if that is an important change, but I don’t think specific indexes are needed here.
The main issue I can see is that your WP_Query has:
'meta_key' => 'status',
'meta_value' => 'te koop',
This will override the 'meta_query' => $arrays
Please only use the 'meta_query' => $arrays
Thanks
E

I think you need to use get_field_object but don’t quote me – I’m learning as well. 🙂
$choices = get_field_object('yourFieldKey');
http://www.advancedcustomfields.com/resources/functions/get_field_object/
BAZINGA!!! I did the php.ini trick as described here
and that seemed to do the work. Fanbloomintastic. Peace out ACF
Thanks for your respons.
I figured it out, I made another if statement within like this:
<?php
if( get_field('te_koop') )
{
if( qtrans_getLanguage() == 'en' ){
echo '<span class="sale">For sale</span>';
}
else
{
echo '<span class="sale">Te koop</span>';
}
}
else
{
echo '';
}
?>
I’m not quite sure what you want to achieve.
What i can say is, that your if statement needs an expression of the type boolean, which your field probably isn’t. (read this)

This is the code I use to display ALL of the releases. It works great.
I need to somehow adapt this query to show only the Releases of a specific artist on their Artist page. Thought it might help…
<?php
$args=array(
'post_type' => 'book',
'post_status' => 'publish',
'posts_per_page' => 12,
'caller_get_posts'=> 1,
'orderby'=> 'date',
'order' => 'DESC'
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo '';
$i = 0;
while ($my_query->have_posts()) : $my_query->the_post();
if($i % 6 == 0) { ?>
<div class="row">
<?php
}
?>
<img src="<?php the_field('cover_image'); ?>" /><br />
<?php the_field('author_name'); ?><br />
<?php the_title(); ?><br />
</div>
<?php
if($i % 6 == 0) { ?>
<?php
}
$i++;
endwhile;
}
wp_reset_query();
?>
Elliot,
Thanks for the quick response. I’m still not clear on how the Relationship Field could be used with Attachments (images) with the ability to see a thumbnail of the image you are selecting. If there is a way, I’d be interested in knowing.
The good news is that I somehow missed the Repeater Field Add-On with the Image Sub Field, and that does look like it would work well for my needs.
I was going to mark this as solved, but just curious about the first part of it if possible. It that part isn’t doable, just LMK and I can call it solved.
Thanks!
-Thomas
Hi Flowbob,
Did you try using something like this in your custom theme page, I used fancybox:
<a class="fancybox" rel="group" href="<?php the_field('name_custom_field'); ?>"><img src="<?php the_field('name_custom_field'); ?>" alt="<?php the_title(); ?>"/></a>
Is $field the search term entered into the relationship search box I tried
function acf_relationship_content_search( $args, $field, $post ) {
$args['s'] = $field;
return $args;
}
add_filter('acf/fields/relationship/query', 'acf_relationship_content_search', 10, 3);
to include the field in the wider search for post_content but no dice.
Any help anyone can give me would be greatly appreciated.
Thanks,
Hi guys,
Thanks for your help firstly! I’m really impressed with the quality of this plugin, I know I’m trying to do something tricky here with only a working knowledge of PHP. Everything else I’ve used ACF for (lots of applications!) works like a charm straight out of the box.
Now.
I tried removing the postdata functions, but that doesn’t seem to have changed anything.
Taking the $idlist declaration out of the loop does seem to have helped- I set up two test repeater rows and posts chosen in both are being affected.
However – only the values from the last repeater row are being applied. I.e. I have two sales, one takes $50 off a group of posts, the second takes $150. Now all the posts selected are showing $150 reduction.
This is the current code I’ve put in a test page template to get the print:
if(get_field('sales', 'option')):
while(has_sub_field('sales', 'option')):
$saletype = get_sub_field('sale_type');
$discount = get_sub_field('discount_amount');
$saleitems = get_sub_field('devices_on_sale');
if( $saleitems ):
foreach( $saleitems as $post):
$thisid = $post->ID;
$idlist[] = $thisid;
endforeach;
endif;
echo($discount);
print_r($idlist);
endwhile;
endif;
Which yields:
100Array ( [0] => 3391 [1] => 3410 [2] => 3412 ) 150Array ( [0] => 3391 [1] => 3410 [2] => 3412 [3] => 1292 [4] => 751 )
So by my understanding, this is adding both groups of selected posts to the same array.
Perhaps during the foreach loop, the $post->$ID can be stored differently… I have a vague idea – what I need is not a single named array, but some kind of anonymous array that can be referenced differently somehow, when I need it?
Alternatively, could I create a “name” text subfield for each repeater row to provide each row with a unique identifier, then reference the related array from that somehow?
Argh! Any further help much, much appreciated! Cheers for having such great support!

Solution if anyone is look for it, managed to figure it out.
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'is_featured_product',
)
)
);
?>
<?php $loop = new WP_Query( $args ); ?>
<div class="nav subnav">
<ul id="menu-top-ten-product-menu" class="menu">
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<li>
<a href="<?php the_field('product_logo'); ?>">
<img src="<?php the_field('product_logo'); ?>" alt="">
</a>
</li>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</ul>
</div>
Of course.
The issue is because of I had changed the value of the choices in a checkbox custom field without I realised I would need update the posts. Now, I’ve many posts with the old value and many others with the new one. This is a problem in searching, but besides, its a problem when is need to edit one posts because the old value selected it doesn’t appears and the update isn’t done because can’t validate ( it’s an required field)
Now I need to verify the value in each post, and update it. I was looking for another solution, may be updating de databse from the plugin.
Thanks a lot
Hi @elliot!
It’s me once again. The simple solution would be the one displayed here
So the following would work for me:
echo ‘flush_all’ | nc localhost 11211
or in PHP something like this:
if ( file_exists( WP_CONTENT_DIR . ‘/object-cache.php’ ) &&
$fp = fsockopen(“localhost”, 11211, $errno, $errstr, 30) ) {
fwrite($fp, “flush_all\r\n”);
$output = ”;
while (!feof($fp))
$output .= fgets($fp, 128);
// do whatever you want with $output… what you should get is “OK”
fclose($fp);
}
Cheers
Günther
Thanks.
I though it would tell me in the WP admin that I needed to update (I checked there before asking the question).
I’ll know for the future that I need to check here for the last version everytime I use it…

Hi @moralejf
The ‘home page’ or ‘blog page’ does not have a global $post object becuase the query is to load the posts.
This means that a get_field call won’t work because ACF doesn’t know which page to load from.
A solution for this is to check if the page is_home:
http://support.advancedcustomfields.com/forums/topic/acf-fields-not-displaying-on-posts-page/

Hi @jhayunu
Thanks for the question. This kind of query has not yet been attempted here, so you will be the first to undertake the task!
Please first read the documentation for querying sub field values:
http://www.advancedcustomfields.com/resources/tutorials/querying-the-database-for-repeater-sub-field-values/
You will need to write some custom SQL to compare between the values, but I’m not entirely sure this can work with a ‘LIKE’ on the meta_name…
Good luck, but this is far beyond the scope of the plugin and I can’t offer too much free support for this one.
Cheers
E
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.