Meta query with ACF relationship field

Based on https://stackoverflow.com/questions/42011047/wordpress-query-by-acf-relationship-field, I was able to fix this by changing the ‘compare’ => ‘IN’ to ‘compare’ => ‘LIKE’. So the resultant code looks like this: $new_query_args = [ ‘meta_query’ => [ [ ‘key’ => ‘af_author’, ‘value’ => get_the_ID(), ‘compare’ => ‘LIKE’, ] ] ]; $query_args = array_merge( $query_args, $new_query_args ); I’m not exactly sure … Read more

Get the featured image of an ACF relationship field

According to ACF documentation, a foreach loop is to be used to access the items in a Relationship field. Untested: $templates = get_field( ‘field_61318c078a746’ ); foreach ( $templates as $template ) { $template_image_id = absint( get_field( ‘Image’, $template ) ); $template_image_url=”https://example.com/fallback-image.jpg”; if ( ! empty( $template_image_id ) ) { $template_image_url = wp_get_attachment_image_url( $template_image_id, ‘large’ ); … Read more

How to get posts in backbone where a custom field matches a value?

The REST API endpoint “List Posts” (e.g. GET /wp/v2/posts) does not support filtering the posts by a post meta (or custom field), therefore passing post meta parameters like meta_key and meta_value will by default do nothing. But the rest_<post type>}_query filter can be used to manually add custom meta queries to the query arguments passed … Read more

Advanced Custom Fields – How do I get field values of a group within a group field type

I should not have been looping at all. This (not optimized) code fixes all issues and adds Difficulty. add_shortcode(‘get_run’, ‘get_run_status’); function get_run_status($atts) { $atts = shortcode_atts(array( ‘run’ => ”, ), $atts); $run_output=””; $diff_output=””; $found_day = false; $found_night = false; $run_atts = sanitize_text_field($atts[‘run’]); $run_query = get_field($run_atts); if($run_query): $run_status = $run_query[‘status’]; $run_difficulty = $run_query[‘difficulty’]; endif; foreach ($run_status … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)