Order ascending is ignored in meta query?
Order ascending is ignored in meta query?
Order ascending is ignored in meta query?
The is_category function checks the queried object. Since this is in pre_get_posts, the query has not happened yet. Check the other parameters to find if the query is going to be for cat 5, not if the results are for cat 5. Try ->get(‘cat’).
If you’re using WordPress 4.2 or newer then you can do the following: $args = array( ‘post_type’ => ‘events’, ‘posts_per_page’ => 10, ‘meta_query’ => array( ‘relation’ => ‘AND’, ‘start_date_clause’ => array( ‘key’ => ‘start_date’, ‘compare’ => ‘EXISTS’, ), ‘ticket_status_order_clause’ => array( ‘key’ => ‘ticket_status_order’, ‘compare’ => ‘EXISTS’, ), ), ‘order_by’ => array( ‘start_date_clause’ => ‘ASC’, … Read more
Applying posts_clauses filter to specific queries only
Based on data from your Gist, the following pre_get_posts condition should work to limit your posts per page. add_action( ‘pre_get_posts’, ‘my_set_category_posts_per_page’ ); function my_set_category_posts_per_page() { global $wp_query; if ( ‘category_sticky_post’ === $wp_query->query_vars[‘meta_key’] ) { $wp_query->set( ‘posts_per_page’, 8 ); } }
Custom Taxonomy Not Working When added to WordPress Search
Use custom post meta in permalink
You can check if you are on a tag page with a conditional, and then modify the main query: add_action( ‘pre_get_posts’, ‘search_the_title’, 1 ); function search_the_title($query){ // Check if it’s the main query if ( $query->is_main_query() && !is_admin()) { // If it’s a tag page, search posts by tag if ( is_tag() ) { $query->set(‘s’ … Read more
This should do it, using pre_get_posts: function wpse_275546_hide_distribution_post( $query ) { /* Don’t filter posts in admin, or the current post when viewing a single post. */ if ( ! is_admin() && ! ( $query->is_main_query() && is_single() ) ) { /** * Get current meta query if it exists, otherwise an empty array. * This … Read more
Dave, your code seems good except a couple things in it, so please try it: function exclude_featured_post( $query ) { if ( is_front_page() && $query->is_main_query() ) { $meta_query = $query->get(‘meta_query’) ? $query->get(‘meta_query’) : array(); // append yours $meta_query[] = array( ‘key’ => ‘featured_post’, // please make sure that key is correct ‘value’ => ‘1’, ‘compare’ … Read more