Any number in meta key (wp query)

You must use LIKE on the meta_key to support the SQL % pattern. The compare attribute only applies to the meta value. Instead you could try to filter it with: /** * Match any numbers in given a meta-key for WP_Query * * @see https://wordpress.stackexchange.com/a/177331/26350 */ ! is_admin() && add_filter( ‘posts_where’, function( $where ) { … Read more

Retrieve value of a category’s custom field

http://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/ prety much covers what you’re after I believe. So in your example while ( $projects->have_posts() ) { $projects->the_post(); $category_classes = array(); $categories = get_the_terms( get_the_ID(), ‘project_category’ ); if ( $categories ) { foreach ( $categories as $category ) { $categories_included[] = $category->term_id; $color = get_field(‘color’, ‘project_category_’.$category->term_id); } } You can also pass a term … Read more

Advanced Custom Fields: Sorting custom columns with custom fields sorts only by date

It appeared it was due to the fact that WordPress doesn’t understand that you need to order by certain post meta unless you specify it. So in my case adding this fixed the sorting issue: add_action( ‘pre_get_posts’, ‘custom_orderby’ ); function custom_orderby( $query ) { if( ! is_admin() ) return; $orderby = $query->get( ‘orderby’); if( ‘featured’ … Read more

Changing a specific value inside a complex repeater/flexible content field (ACF)

Answering my own question again. 😛 I finally found this Gist that lets me get and set array variables via dot notation: https://gist.github.com/elfet/4713488 So I included the DotNotation class and now my code looks like this (skipping all sorts of error checking here) : $fieldmap_string = ‘key1.key2.key3.etc’; $current_page_content = get_field(‘page_content’, $source_post_id); $parsed_current_content = new DotNotation($current_page_content); … Read more

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