Merge wp-query and get_users
Merge wp-query and get_users
Merge wp-query and get_users
Look for string in posts and postmeta
This is what I ended up with: $specialty_terms = get_terms(‘specialty’); $specialty_term_ids = wp_list_pluck($specialty_terms, ‘slug’); $location_terms = get_terms(‘locations’); $location_term_ids = wp_list_pluck($location_terms, ‘slug’); if( isset($_GET[‘docname’]) ): $name_search = $_GET[‘docname’]; else: $name_search = “”; endif; if( isset($_GET[‘specialty’]) && $_GET[‘specialty’] !== ”): $specialty = $_GET[‘specialty’]; else: $specialty = $specialty_term_ids; endif; if( isset($_GET[‘location’]) && $_GET[‘location’] !== ”): $location = $_GET[‘location’]; … Read more
wp_reset_query is meant to be used with a loop, because it resets the global $wp_query object. get_posts, on the other hand, just returns an array to be iterated with ie. foreach. setup_postdata does not populate the $wp_query object: https://codex.wordpress.org/Function_Reference/setup_postdata. For a custom query, you would either use the WP_Query class, or you could reset your … Read more
wp_get_current_user() does not return all the data for the user, you should try using get_user_meta(). Try as below $company = get_user_meta($current_user->ID,’company’); $mf_group = get_user_meta($current_user->ID,’mf_group’); and in your post loop changes this two lines as below ‘company’ => $company[0], ‘mf_group’ => $mf_group[0], Hope this helps.
Try using this syntax below : $query->set(‘orderby’, array(‘title’ => ‘ASC’, ‘meta_value’ => ‘ASC’)); // $query->set(‘order’, ‘ASC’ ); // not needed any more
It is not the most elegant solution, but you could sort the results on your search page: At the top of your page, make the wp_query variable available global $wp_query; Later in you code, if there are some results : if ( have_posts() ) { //your desired order $order = array(45, 78, 94); // a … Read more
Getting user’s metas values : $user_meta = get_user_meta($user_id, ‘YOUR_META_KEY’, TRUE); //You have to set the $user_id / And the “YOUR_META_KEY” can be description, name, custom meta… To get user’s comments count function commentCount($userId = null) { global $wpdb; if($userId == null) return 0; $count = $wpdb->get_var(‘ SELECT COUNT(comment_ID) FROM ‘ . $wpdb->comments. ‘ WHERE user_id … Read more
WP Query. Ordering posts by another post types meta
Modify a query with no results in pre_get_posts