Sort posts by Date (DESC) and by Title (ASC)

You can pass an array to the query as the following example described in the Codex shows: $args = array( ‘orderby’ => array( ‘title’ => ‘DESC’, ‘menu_order’ => ‘ASC’ ) ); $query = new WP_Query( $args ); In your case will be something like this: /* Order Posts Alphabetically */ function prefix_modify_query_order( $query ) { … Read more

Add class to menu items of one specific menu (nav_menu_css_class)

I was also trying to solve this problem and while searching for a solution, discovered that the nav_menu_css_class filter actually excepts a third parameter. This is an object containing variables related to your menu and includes the theme_location variable you can use to conditionally apply class names to a specific menu. You just need to … Read more

Does hooking into the same action multiple times drain memory?

I guess you mean add_action( ‘pre_get_posts’, ‘private_groups’ ); add_action( ‘pre_get_posts’, ‘search_results’ ); add_action( ‘pre_get_posts’, ‘name_profiles’ ); versus add_action( ‘pre_get_posts’, ‘combined_into_single_callback’ ); You can just check the difference using e.g. memory_get_usage() and timer_stop(). Many good plugins out there to help with that. I would say go with the first one, as they seems to be unrelated … Read more

Possible to search by author name with default WordPress search function?

Maybe you can try adding your condition directly in the query string, using something like this function wpse_29570_where_filter($where){ global $wpdb; if( is_search() ) { $search= get_query_var(‘s’); $query=$wpdb->prepare(“SELECT user_id FROM $wpdb->usermeta WHERE ( meta_key=’first_name’ AND meta_value LIKE ‘%%%s%%’ ) or ( meta_key=’last_name’ AND meta_value LIKE ‘%%%s%%’ )”, $search ,$search); $authorID= $wpdb->get_var( $query ); if($authorID){ $where = … Read more