advanced-custom-fields

WordPress: How to sort content by ACF custom field?

不羁的心 提交于 2019-12-07 07:31:56
问题 With use of the Advanced Custom Fields plugin I created a select dropdown which contains 6 membership types. All of my 'listings' using this custom field are assigned one of the 6. I'd like to display all 'listings' by: Ultimate Plus Ultimate Professional Commercial Business Free In this particular order, so those paying for the highest level membership have their 'listing' appear at the top of the page. I expected it to be similar to this which I just found but unsure exactly: // args $args

Get advanced custom fields repeater field value based off of another repeater value

你说的曾经没有我的故事 提交于 2019-12-06 20:16:30
I have a repeater field on a page, in that field i have a post object field and a few text fields. The post object field just gets the ID of whatever post you set. When i am a single post i want to run a database query that uses the current post ID to find the matching sub field, then get another sub field in that same repeater field. Can anyone help with this? This is what i have so far which is not want i need but its the closes it have been able to get $games_id_array = $wpdb->get_results( $wpdb->prepare( " SELECT * FROM wppp_postmeta WHERE meta_key LIKE %s AND meta_value LIKE %s ",

How to get real term_meta using ACF with custom fields on taxonomy terms (instead of wp_options)

ぐ巨炮叔叔 提交于 2019-12-06 16:17:48
Having a simple Woocommerce site, I'm using ACF pro to add some custom fields to the terms of a given taxonomy. Using this, I can, for example, add a "color" field to my "product category" taxonomy terms. Good. The issue: Wanting to do some query using get_terms() ( codex ), I discovered that my meta_query parameters were not working (unexpected results). Why ? My custom fields were not saved (from backend) as term_meta but as wp_option . It seems that ACF 4 is saving those fields, not as term_meta (as it's designed for), but as wp_option , in the Wordpress options table. So you cannot "query

Meta Query Posts by Sub Field Value ACF

馋奶兔 提交于 2019-12-06 09:58:28
问题 I am attempting to query posts by those with sub field values of 'audi'. I have looked and looked but cannot find an answer. The $args I have are below, and posts exist in the database which match 'audi' as the value for sub field 'model' of repeater 'cars'. $args = array( 'post_type' => 'manufacturers', 'meta_query' => array( array( 'key' => 'cars_%_model', 'value' => 'audi', 'compare' => 'LIKE' ) ) ); $query = new WP_Query($args); Any hints as to where this code falls down would be really

WordPress Advanced Custom Fields Repeater, wrap every 3 divs in a row

落爺英雄遲暮 提交于 2019-12-06 09:29:39
I'm using Advanced Custom Fields, and I would like to wrap every 3 divs in a row. If there is a fourth div or 2 extra then those would get wrapped in their own row. So open and close with a row. I currently have the basic output but all my current attempts to add the counter have failed. Any help would be appreciated <?php // wrap every 3 divs in a row if(get_field('triple_column_2')): ?> <?php while(has_sub_field('triple_column_2')): ?> <div class="col-sm-4"> <?php the_sub_field('copy'); ?> </div> <?php endwhile; ?> <?php endif; ?> You can use this as a starting point. I haven't tested it so

Advanced Custom Fields - Wordpress

删除回忆录丶 提交于 2019-12-06 03:42:20
While using the Custom Fields Plugin , I cannot get it to return any data. I have created a field group called book_cover_thumbnail which has one post linked to it. Can anyone see why the code below would not work? <img src="<?php get_field('book_cover_thumbnail');?>" /> I get no errors at all, no white space. Nate F. Make sure you are a) Echoing the field using either the_field() or echo get_field() , and b) this code is either within the wordpress loop like this: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>` <img src="<?php echo get_field('book_cover_thumbnail');?>" />

Wordpress: Archive page with Filter doesn't work (ACF)

纵饮孤独 提交于 2019-12-06 01:51:33
问题 Im trying to filter my custom post types by a checkbox field of ACF. I work with this tutorial: https://www.advancedcustomfields.com/resources/creating-wp-archive-custom-field-filter/ Now I got the problem that nothing change, when ich filter over the checkboxes on the archive page of the custom post type. It generates only the right URL but doesn't filter the posts. Does some have any idea why? function.php: // array of filters (field key => field name) $GLOBALS['my_query_filters'] = array(

WordPress query posts by ACF

余生颓废 提交于 2019-12-05 23:16:14
UPDATE - SOLVED Okay so I have three custom post types 'courses', 'modules' and 'results'. These post types are set up with a number of ACF (Advanced Custom Fields). I'm trying to query the 'results' CPT based on their ACF's using 'meta_query'. The two ACF fields I'm trying to query with are 'module' and 'user'. 'module' - Set up as a 'Relationship' field type filtering the 'module' custom post type. 'user' - Set up as a (Relational) 'User' field type. I seem to only get an empty array back. I've looked at the examples on https://www.advancedcustomfields.com/resources/query-posts-custom-fields

Wordpress Gravity Forms get List values

与世无争的帅哥 提交于 2019-12-05 20:51:33
Can somebody point me in the direction on how to extract values from submitted forms containing list fields? I'm trying to create a front-end posting form using Gravity Forms, and then having the submitted values be assigned to custom fields made with Advanced Custom Fields. For normal fields, you can do this with the following: add_action("gform_after_submission_1", "acf_submission", 10, 2); function acf_submission($entry, $form) { $post_id = $entry["post_id"]; update_field('field_###', $entry['#'], $post_id ); update_field('field_###', $entry['#'], $post_id ); update_field('field_###',

WordPress: How to sort content by ACF custom field?

╄→гoц情女王★ 提交于 2019-12-05 15:41:23
With use of the Advanced Custom Fields plugin I created a select dropdown which contains 6 membership types. All of my 'listings' using this custom field are assigned one of the 6. I'd like to display all 'listings' by: Ultimate Plus Ultimate Professional Commercial Business Free In this particular order, so those paying for the highest level membership have their 'listing' appear at the top of the page. I expected it to be similar to this which I just found but unsure exactly: // args $args = array( 'post_type' => 'directory_listings', 'meta_key' => 'free', 'orderby' => 'meta_value_num',