“tax_query” parameter not working with WP_Query

I have a custom post type called ‘episode’. Attached to ‘episode’ I have a custom taxonomy called ‘video_type’ that contains two terms: “bonus-footage” and “episode”; “episode” contains two child terms “season-1” and “season-2” (other seasons will be added in the future). I want to grab only the most recent post of the ‘episode’ type but … Read more

Is it necessary to use wp_reset_query() in a WP_Query call?

I’m using the following code to retrieve posts: <?php $featuredPosts = new WP_Query(); $featuredPosts->query(‘showposts=5&cat=3’); while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); ?> <h1><a href=”https://wordpress.stackexchange.com/questions/8031/<?php the_permalink() ?>”><?php the_title(); ?></a></h1> <div class=”meta”> By <?php the_author() ?> </div> <div class=”storycontent”> <?php the_excerpt(); ?> </div> <?php endwhile; ?> Do I need to use wp_reset_query()? If I do, where should I place it? … Read more

Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title

I’m working on a custom taxonomy term page template where we want the items that are connected to the term sorted by a publication date (custom date field) – and if there are multiple items on the same day (formatted like YYYY-MM-DD) to then sort those by title, and finally sort by title if the … Read more

Nested meta_query with multiple relation keys

I am curious whether WordPress is able to run nested meta_query, with each having different relation keys? As of WordPress 3.0, tax_query is able to perform this function; I’m wondering whether this has an equivalent with meta_query. $results = query_posts( array( ‘post_type’ => ‘event_id’, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘relation’ => ‘OR’, array( … Read more

How can i retrieve default post per page value? from settings->reading. And total number of posts?

I want to retrieve the default value of Post per page (the value that is set in settings->reading. I’ve looked around and so far I’ve only found ways to query it. problem is i dont want to change what was set i just want to retrieve it for pagination purposes. i thought of using $something->post_count.(i … Read more

Should I use Pre Get Posts or WP_Query

I have the following query which I call in my taxonomy.php template via query_brands_geo(‘dealers’, ‘publish’, ‘1’, $taxtype, $geo, $brands); This function works perfectly. However after reading codex for query posts it mentioned pre_get_posts as a preferred way to alter the default query. Would the pre_get_posts be more efficient then my wp_query function below? If so … Read more

How to print the excuted sql right after its execution

I am searching for a way by which i can print the executed sql query just after the : $wpdb->query( $wpdb->prepare(“INSERT INTO tbl_watchprosite SET keywords=%s,url_to_post=%s,description=%s, date_captured=%s,crawl_id=%d, image_main=%s,images=%s,brand=%s, series=%s,model=%s,condition=%s,box=%s, papers=%s,year=%s,case_size=%s,status=%s,listed=%s, asking_price=%s,retail_price=%s,payment_info=%s,forum_id=%d”, $this->getForumSettings()->search_meta,$element->href,$post_meta[‘description’],current_time(‘mysql’),$cid,$post_meta[‘image_main’],$images,$post_meta[0],$post_meta[1],$post_meta[2],$post_meta[3],$post_meta[4],$post_meta[5],$post_meta[6],$post_meta[7],$status,$post_meta[9],$post_meta[10],$post_meta[11],$this->getForumSettings()->ID) ); This would be great if i can see what values are going in the query. Thanks 4 The $wpdb object has some properties … Read more