Help ordering Post loop by two meta values

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

Alter query using pre_get_posts() if meta_key is present

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 ); } }

WordPress Tag or Custom Taxonomy Return All Posts if has that Word in Post Title

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

Exclude posts from main loop based on meta value

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

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