wp_query, give first post different formatting

Hope I’m understanding you correctly could you not just do something simple like this $args1 = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 4 ); $loop = new WP_Query($args); while ($loop->have_posts()) : $loop->the_post(); echo ‘<h2><a href=”‘.the_permalink().'”>’.the_title().'</a></h2>’; if ($loop->current_post == 0) { echo the_post_thumbnail(); echo the_excerpt(); } endwhile; wp_reset_postdata();

How to filter by custom post type in taxonomy archive pages

That is the normal behaviour. If you go the archive of one taxonomy term you will get all posts, of any type, with this taxonomy term. One solution can be, for example, adding ?custom_type=files or ?custom_type=questions to your URLs and alter the main query in the pre_get_posts filter: add_action( ‘pre_get_posts’, ‘my_pre_get_post’ ); function my_pre_get_post($query){ if(!empty($_GET[‘custom_type’])){ … Read more

Query current and future events, ordered by begin date

This happens because of the OR relation on meta_query and the way WordPress generates the actual query string. You need to leave out the meta_key and orderby from the query args and hook into the posts_clauses filter to modify the where and orderby pieces of the query: function wpse_130954_orderby_fix($pieces){ global $wpdb; $pieces[‘where’] .= ” AND … Read more

Custom Field sort not working (WP 3.8.1)

I think your query arguments are missing meta_key, which in this case should be ‘event-date’. You need it outside the meta query for orderby to work. Try this: $today = date(“Ymd”, strtotime(current_time(‘mysql’))); $args = array( “post_type” => “post”, “post_status” => “publish”, “posts_per_page” => -1, “cat” => 13, “meta_query” => array( array( “key” => “event-date”, ‘type’ … Read more

WP_Tax_Query with post_tag not working

I did get the thing working, though I’m not entirely sure how. I made two changes: Removed the “convert array to Tax_Query object” step (which I only put in because using an array wasn’t working before) Added a direct assignment of the array to the $query object (rather than just using the set() method). My … Read more

Date query not inclusive despite parameter being true

If you only want to work with yyyy-mm-dd strings, for example ‘2014-10-10’, you could do something like: ‘before’ => ‘2014-10-10 + 1 day – 1 second’, ‘before’ => ‘2014-10-10 + 86399 seconds’, ‘before’ => ‘tomorrow 2014-10-10 – 1 second’, ‘before’ => ‘2014-10-10 tomorrow – 1 second’, or just append ’23:59:59′ to your yyyy-mm-dd string to … Read more

Query wp_usermeta alongside wp_users

This is not a simple answer, so first you will need to include one more filter to allow you to grab both the make the meta_query interact with the main query via an OR instead of a AND, check my sample of code: add_filter(‘user_search_columns’, ‘q166419_user_search_columns’ , 10, 3); function q166419_user_search_columns($search_columns, $search, $this){ if(!in_array(‘display_name’, $search_columns)){ $search_columns[] … Read more