Showing an ACF field in admin posts dashboard

This code worked perfectly fine: function custom_columns( $columns ) { $columns = array( ‘cb’ => ‘<input type=”checkbox” />’, ‘title’ => ‘Title’, ‘featured_image’ => ‘Image’, ‘categories’ => ‘Categories’, ‘amazon_url’ => ‘Amazon Link’, ‘comments’ => ‘<span class=”vers”><div title=”Comments” class=”comment-grey-bubble”></div></span>’, ‘date’ => ‘Date’ ); return $columns; } add_filter(‘manage_posts_columns’ , ‘custom_columns’); function custom_columns_data( $column, $post_id ) { switch ( … Read more

How to update a custom post title from a front-end form using ACF fields?

You check if !$value before assigning the title from the fields, that test will be false once the post has a title. If you always want it to update, then remove the test. function auto_title_insert() { return $_POST[‘fields’][‘field_538626f57e84c’].’ ‘.$_POST[‘fields’][‘field_538627ffeccb0′].’ ‘.$_POST[‘fields’][‘field_53863a5c7502b’].’ ‘.$_POST[‘fields’][‘fields[field_53a9bb09f82ba]’]; } add_filter( ‘title_save_pre’, ‘auto_title_insert’ );

Advanced custom field – gallery – display one random image

Shouldn’t you be doing something like this? <img src=”https://wordpress.stackexchange.com/questions/99655/<?php echo $rand[“url’]; ?>” alt=”https://wordpress.stackexchange.com/questions/99655/<?php echo $rand[“alt’]; ?>” /> Update I’m not really familiar with that plugin (stuff could be happening behind the scenes) but here’s a better guess than my previous one: <?php $gallery = get_field(‘gallery_home’); $rand = array_rand($gallery, 1); if( $gallery ): ?> <img src=”https://wordpress.stackexchange.com/questions/99655/<?php … Read more

Get the label from ACF checkbox [closed]

You can try this $field = get_field_object(‘color’); $colors = get_field(‘color’); // array of selected color values foreach($colors as $color){ echo “selected color: “. $color. ” with label: ” . $field[‘choices’][ $color ]; } where the labels are fetched by get_field_object according to the link you provided. You could also use print_r() or var_dump() to check … Read more

Query between dates using Date Picker fields

The Codex lists all of the comparison options on the WP_Query page. If you want events with a start date BETWEEN a range of dates, OR events with an end date BETWEEN a range of dates, something like this should work – ‘relation’ => ‘OR’, array( ‘key’ => ‘event_start_date’, ‘value’ => array( $beginning_of_range, $end_of_range ), … Read more

WP REST API: Order posts by meta value (acf)?

I’m guessing you haven’t exposed meta_key and meta_value to the REST API with the rest_query_vars filter, so this should do it: function my_add_meta_vars ($current_vars) { $current_vars = array_merge ($current_vars, array (‘meta_key’, ‘meta_value’)); return $current_vars; } add_filter (‘rest_query_vars’, ‘my_add_meta_vars’); Then you can refer to meta_key and meta_value in your query. Be aware that this obviously exposes … Read more

Returning all radio button options when using Advanced Custom Fields

Check out this page in order to discover your field key for your radio button: http://www.advancedcustomfields.com/docs/functions/get_field_object/ Next, insert this code where you are grabbing your field values: <?php $key = ‘your_fieldkey_here’; $field = get_field_object($key); if ($field) { foreach ($field[‘choices’] as $key => $value) { echo (‘KEY : ‘ . $key); echo (‘<br />’); echo (‘VALUE … Read more