Can’t sort custom column on user.php by number / meta_value_num?

Instead of ‘request’ function, use this : add_action(‘pre_user_query’, ‘user_column_orderby’); function user_column_orderby($userquery){ if(‘Votes’==$userquery->query_vars[‘orderby’]) { global $wpdb; $userquery->query_from .= ” LEFT OUTER JOIN $wpdb->usermeta AS alias ON ($wpdb- >users.ID = alias.user_id) “; $userquery->query_where .= ” AND alias.meta_key = ‘wp__user_like_count’ “; $userquery->query_orderby = ” ORDER BY alias.meta_value “.($userquery->query_vars[“order”] == “ASC” ? “asc ” : “desc “); } }

update_post_meta based on acf repeater field

/** * Function: update_acf_repeater_field * Parameters: $meta_type = post|user|comment * $field_group_name = the name of ACF Field Group * $repeater_field_name = the repeater field name * $subfields = a multidimensional array with the array keys matching the * the sub field names, e.g., array(array(‘subfield_name’=>’value’,’subfield_name’=>’value’)) * $post_id = the post id, user id or comment id … Read more

How to add google map to custom field

It looks like you’re missing some code according to the ACF docs – see example under “Required CSS & JS” – http://www.advancedcustomfields.com/resources/google-map/ Sadly – this page of the ACF documentation may be out of date. According to google maps API docs – you’ll need to create an API key for all their APIs (Embed, JS, … Read more

Show only first image of multiple image field

Below are four examples of getting a list of items, returning the first and showing a single image from the first id. explode assumes your data is in a string separated by commas. get_attached_media pulls all the attached items in a post then renders the first from that list get_post_meta assumes the data lives in … Read more

How to show all posts of specific custom post type with their custom fields values?

The meta information is in a different db table from my understanding. What you’ll need to do is loop through each post and grab it’s meta data using get_fields(). Below is a sample from the query to find all the fields for a particular post. $rows = $wpdb->get_results($wpdb->prepare( “SELECT option_name, option_value FROM $wpdb->options WHERE option_name … Read more

Filter Query Post by Custom Fields(by date)

As already said, your query arguments are slightly off – meta_query should be an array of arrays: $query = new WP_Query( array( ‘category_name’ => ‘events’, ‘order’ => ‘DESC’, ‘orderby’ => ‘meta_value’, ‘meta_query’ => array( array( ‘key’ => ‘start_date’, ‘value’ => strtotime( ‘today’ ), ‘compare’ => ‘>=’, ‘type’ => ‘UNSIGNED’, // Ensure MySQL treats the value … Read more

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