Articles of advanced custom fields

ACF no print data

I’ve a problem with Advanced Custom Fields Plugin I create a custom field named: bgcolor I want to print the value in category.php, this is my code: $color = get_field(‘bgcolor’, ‘category_’.the_category_ID( $echo ).”); echo $color; What its wrong? Thanks

Conditional custom redirect

I want to achieve the following: On a post or a page, I can define an optional custom redirect URL (possibly as an Advanced Custom Field) If I view this post/page with a specific added URL parameter (like “?redirect=true”, send a redirect to the defined custom URL, otherwise do not redirect. My naive approach would […]

Google Places API With ACF

I’m creating a site that has a Venue custom post type, and one of the custom fields (using advanced custom fields) is the hours of operation for the business. I was going to manually find this information and plug it in myself, but that’s a lot of work, and it changes seasonally, which Vermont has […]

How can you query posts by advance custom field when the value is a serialized array?

Bottom for resolution Im going crazy I think. I cannot figure this out for the life of me. I have an advanced custom field that is a select box. The select box has multiple values and allows for multi-selections. I made 1 post and multi-selected 3 values in this drop down. I now need to […]

ACF Relationship – Exclude pages not created by author

I have pages that I would like to exclude in a ACF relationship field. My field name is products and the following code excludes the pages with id 9, 10 or 11. add_filter(‘acf/fields/relationship/query/name=products’, ‘exclude_id’, 10, 3); function exclude_id ( $args, $field, $post ) { $args[‘post__not_in’] = array( $post, 9, 10, 11 ); return $args; } […]

Get ACF fields in relationships of returned post

I know to get the ACF fields of a post it’s self but I’m having trouble getting relationships within those results to return ACF fields as well. example: $args = array( ‘post_type’ => ‘location’, ‘post__in’ => array(67) ); $q = new WP_Query($args); $locations = array(); while($q->have_posts()) : $q->the_post(); $p = get_post(); // gets the basic […]

Show only the future event (Advanced Custom Fields)

I’m trying to make event ticker with Advanced Custom Fields and I want to show only events that are happening on the current day or in the future. But I don’t know how to hide past events. Could anyone help me, please? This is my code. It works fine, but it doesn’t hide past events. […]

How to disable field on Advanced Custom Fields?

I create Repeater field table for Advanced Custom Field plugin, I set location show on User, but I want User only views not edit. and Admin will edit. So, how to disable field edit on User?

Random images with no duplicates (ACF Gallery)

I have a gallery field created with Advanced Custom Fields. My code spits out all the images on a page. So far so good. I would like all the images to load in random. I tried to use shuffle() and array_rand(). That works fine, it loads my images in random order. My issue is duplicates. […]

wpdb and acf via wp rest api

I made a custom endpoint with wp rest api for /wp-json/dn/locations which in turn runs the following wpdb query $sql = “SELECT * FROM wp_posts p WHERE p.post_type = ‘location’ AND p.ID = 133;”; $results = $wpdb->get_results($sql); Which returns fine but unfortunately my ACF fields aren’t showing up in there. There are quite a few […]