Tag Info

Hot answers tagged

2

First of all, never ever use query_posts. It breaks the main function and all plugins and functions relying on the main query object. For custom queries, use WP_Query or get_posts if aren't looking to paginate the query As for the following line 'orderby' => 'rr_recommends_count', I can tell you that rr_recommends_count is an invalid value to the ...


1

First pass for a solution. It uses the new meta sorting that was introduced in 4.2: <?php $args = array( 'posts_per_page' => -1, 'meta_query' => array( 'relation' => 'OR', 'ongoing' => array( 'key' => 'prog_ongoing', 'value' => 1 ), ...


1

One problem with the query is that the self-join with the ambiguous WHERE gives you a crossed dataset (which is masked by the DISTINCT), so it would be simpler to use wp_post as a base to attach the joins that precisely match the keys, eg SELECT p.ID, key1.meta_value as prog_ongoing, key2.meta_value as prog_date_start FROM ...


1

You need to use the user_search_columns filter to add the columns you want to search on. The user_search_columns filter is used to determine which user fields in the database are used when performing a search on user information. https://codex.wordpress.org/Plugin_API/Filter_Reference/user_search_columns


1

In the case that the start_date custom field only exists for the event post type, this works: $query->set( 'meta_query', array( 'relation' => 'OR', array( 'key' => 'start_date', 'compare' => 'NOT EXISTS', ), array( 'key' => 'start_date', 'value' => $today = date( 'Ymd' ), 'compare' ...



Only top voted, non community-wiki answers of a minimum length are eligible