"wp-query" ambiguously refers to one of two things. 1) WP_Query is a class native to Wordpress which allows users to query the posts database using a number of criteria. 2) $wp_query is the default object that holds the main query object on each WordPress page.

learn more… | top users | synonyms

0
votes
2answers
522 views

WP Query and multiple pages

Can anyone tell me why this isn't working? Assuming two things here - 1. WP Query handles multiple page requests, and 2. doesn't need a reset because I'm creating a new WP Query. What happens is I ...
0
votes
1answer
865 views

How do I list a custom field and custom taxonomies for each result in a loop?

How do I list a custom field and custom taxonomies for each result in my loop below? <?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); ...
1
vote
1answer
285 views

Display upcoming Events for next 7 Days

I saw a request for a simple 7 day event calendar that always starts with today. I have a custom meta box called opening-time that gets a YYYY-MM-DD input. For now this is what I have, and its not ...
0
votes
1answer
306 views

Compare meta_query decimals not working right

I have a custom field named 'rating' that holds decimals from 1.0 to 10. I am trying use wp_query to get me all the posts with a rating of 8.0 to 10. What I have so far almost works perfectly but it ...
1
vote
3answers
1k views

Using new WP_Query in shortcode in a custom field causes the main post content to not display

I've got a custom post type of files I'm trying to list using a new WP_Query. It works fine when I add the shortcode within the main post content. However, when I add the shortcode to a custom field ...
0
votes
1answer
65 views

How do I query posts and have their related taxonomies returned in the results?

I have created a custom post type that contains television channel data. Each channel has its own post. I have also created a custom taxonomy of channel groups. What I want to do is query all the data ...
0
votes
1answer
399 views

How to limit posts to 1 from each term with tax_query?

Need 1 post from each. <?php global $post; // required $args = array ( 'tax_query' => array ( 'relation' => 'AND', array ( ...
1
vote
2answers
374 views

Mysql query LIKE not working

I'm using this code. $blog_list = $wpdb->get_results( "SELECT " . $extra . "blog_id, last_updated FROM " . $wpdb->blogs. " WHERE public = '1' AND archived = '0' AND mature = '0' AND spam = '0' ...
1
vote
1answer
2k views

How to grab metabox value in wp_query meta_query key

How would I modify my WP_Query in order to get a custom meta box value instead of a custom field one like I currently do? This is how my query looks like: <?php $today = ...
0
votes
3answers
484 views

Using next/previous_posts_link with customised search

I have a few different searches on my website: "Species profiles" (custom post type search) "Glossary" (custom post type search) Generic, site-wide search Currently I'm using search.php; ...
1
vote
1answer
178 views

How does order=asc effect a wp_query (its acting pretty weird in a loop)

I have a wp_query for a custom post type: events. I have a seven day calendar that is showing featured events on a page. Here is the wp_query and supporting code: https://gist.github.com/1030760 ...
1
vote
2answers
4k views

WP_Query to get posts in a specific category and post format

I've been trying to utilize either WP_Query or get_posts to pull out the most recent post that's both in a specific category and of a specific post format. <?php $singargs = array( 'numberposts' ...
0
votes
2answers
261 views

Second wp_query doesn't appear to be working

I've set up this query in Wordpress to find all associated news for a company: <h2 class="heading">Related News</h2> <?php $link = get_the_title(); ?> <?php ...
0
votes
1answer
3k views

WP Query to get all posts (including in draft/pending review)

I currently have the following query: $args = array( 'post_type' => 'post', 'orderby' => 'title', 'order' => 'ASC', ...
0
votes
1answer
175 views

the_post(); prints out style text into my HTML?

Every time I use the_post(); in my theme code, the following is echo'ed into my pages: <style type="text/css"> <!-- .formTitle { font-size:20px; font-weight:bold; ...
1
vote
1answer
271 views

Sorting By Custom Posts With Attachments

I think I've got this figured out and I'd like to make sure I'm not missing anything obvious. My goal is to prioritize a list of results by custom posts with attachments. So, I have a query returning ...
0
votes
2answers
501 views

Wordpress posts for multiple years

Trying to get posts from a specific category for specific years. Nothing is working, including this: <?php $args=array( 'cat' => '11', //Category I'm targeting 'year' => 2008,2009,2010 ...
0
votes
1answer
674 views

Wordpress query by multiple Custom fields and order by date

So here is my query: $args = array( 'post_type' => 'Event', 'posts_per_page' => 1000, 'meta_key' => 'event_informations_show_on_the_homepage', 'meta_value' => 'Show on ...
1
vote
1answer
456 views

Sorting posts DESC based on the number of comments using WP_Query

I have this unusual requirement from my client that I need to accommodate. They want to be able to view the posts with the largest number of comments first. At first I thought using a custom select ...
1
vote
1answer
609 views

How to display specific posts with WP_Query?

I need some help with displaying some specific WordPress posts. User's on my site can click on an 'Add to favorite' link which will then store that post ID in the user_meta table for that user as an ...
0
votes
1answer
404 views

Get Child Custom Post Content on Single.php?

I have a custom post type, with children 2 rows deep... Outfit 1 Inner Child 1 Child 1 Child 1 Child 1 Outfit 2 Inner Child 1 Child 1 Child 1 ...
3
votes
3answers
1k views

Creating two database tables via plugin

I'm working on a voting plugin for my site and I want to create 2 tables: one that stores votes and another that stores voter ips. In Codex it suggests to use an if statement to see if the table has ...
0
votes
2answers
2k views

Query custom taxonomy by term id?

I made a custom post type and a custom taxonomy, but I have a problem. When I access the url http://www.ithemes.co.kr/?shopcat=galaxy-s, it works well. But when I access the url ...
0
votes
3answers
317 views

Page and post loop same template

I try to make template that has Page content in the main div but in the same page there is category base post loop whit title, day, content and read more link. What i had now is like this <?php ...
0
votes
2answers
664 views

how to compare different timestamps in wp-query for events custom post types?

I have a custom post type with custom metaboxes (as seen on wptheming.com) and would like to make a query to show upcoming events, say in the sidebar, where past dates are left out. But I need a ...
0
votes
1answer
80 views

How can I check for a thumbnail in WordPress?

How can I can I check if a post has a thumbnail and if does do something? If doesn't do something else. This is what I have: <?php if (has_post_thumbnail()) ?> <?php the_thumbnail(); ...
1
vote
2answers
192 views

What is considered a default query for the request filter?

As stated in one of the answers in this question and in the codex entry for the request filter, said filter gets called only in a default query, such as the main query used for a loop. My question ...
0
votes
1answer
70 views

difference between methods of query

Looking in other plugins/widgets code , I usually see TWO different methods for a query : one would be : $args = array( 'numberposts' => $limit , // or, 1, or 20 ... 'exclude' ...
0
votes
1answer
1k views

Adding session variable and/or cookie based on user-selected input

I am working on a classifieds website that has a custom taxonomy called 'countries'. In the main header menu I have these categories showing in a dropdown list of particular countries people can ...
2
votes
1answer
389 views

Multiple Queries and Excluding Repeating Posts?

I'm trying to work out how to exclude posts used in the first four custom queries in the last typical query.. haven't been able to find anything that will explain how to do this clearly. My First ...
0
votes
3answers
153 views

Order by title without taking into account 'the'

I currently have episodes from a TV Show that feature bands playing, so for example I have: Moby The Dandy Warhols The Kooks My wp_query looks like this: $loop = new WP_Query(array('post_type' ...
0
votes
1answer
5k views

How to include category name/id in wp_query for retrieving “custom post type” from a particular category?

Here is the code I'm using right now. It fetches the posts from all the categories in the 'sp_events' post type. <?php $feat_art = new WP_Query(array('post_type' => 'sp_events','post_status' ...
0
votes
2answers
250 views

Admin: Custom Query Returning Permissions Error

Our current WordPress install has a few custom tables we've placed into the WP database that hold misc. information. We've created custom option pages for the WP admin panel for our WP admin users to ...
1
vote
4answers
773 views

Using one WP_Query object within the loop of another WP_Query object

I'm creating two different WP_Query objects, one for each of two different post types I'm using. In creating my output, I'd like to loop through one of the objects, and at the same time loop through ...
1
vote
3answers
3k views

how to group custom post type posts by custom taxonomy terms

I would really appreciate if you could help me :) I'm very stuck and don't know how to proceed. I have a custom post type called event and 2 custom taxonomies registered for it: event_type with ...
0
votes
3answers
3k views

How to make WP_Query 'post__in' accept an array?

I have a function that returns a comma separated list of post ids that a particular user can access. I want to use this list in a WP_Query loop. The custom function: $array = user_albums(); foreach( ...
4
votes
1answer
447 views

How-to exclude terms from the main query the most performant way?

This Q is a follow up to this answer on the Q: "How to exclude a specific term for the search?". 4 ways to filter out posts that have a specific term Type | Pro | ...
2
votes
1answer
363 views

Order by value in serialized custom field

Quite a pesky problem here. I've taken over a site that contains multiple information, serialised, within a custom field. For example: if ($new_query->have_posts()) : while ...
0
votes
2answers
112 views

Getting a custom post's custom field based on another custom post's custom field select

So I'm at my wit's end here. I've done this before plenty of times, but I think I have stared at this so much I am missing something. I basically have a custom post called locations. That custom ...
1
vote
1answer
870 views

Order posts using a custom array

I have an array of post ids which I'm passing to query_posts using 'post__in'. My question is how can I use the order from my array rather than ordering by 'date' etc?
0
votes
1answer
1k views

next_post_link / previous_post_link not working with WP_Query

I am trying to add next and previous page buttons to my template, but when I try to use either next_post_link or previous_post_link, it just does not work. Could it be because I am using WP_Query? ...
0
votes
2answers
6k views

How to display posts month by month?

How could wp-query be used to show posts month by month, and have it only show the past year? Or is it possible some wp_archive hack could handle this?
0
votes
4answers
3k views

Using WP_Query with multiple loops on one page in search.php

I'm trying to set up a search page that first shows a Loop with all posts with a Custom Field meta_key of 'seek_premium' where it's meta_value is 'yes', and then a second Loop where the meta_value ...
10
votes
1answer
8k views

numberposts? showposts? posts_per_page?

So the documentation on the Codex is pretty clear that showposts is deprecated. But that same documentation mentions nothing of numberposts. Instead, posts_per_page is listed. But if we turn to the ...
0
votes
1answer
581 views

Difference between 'LIKE' and 'IN' in meta queries

You can use a variety of different comparison operators in meta queries, among which are 'LIKE', 'NOT LIKE', 'IN', and 'NOT IN'. What is the difference in use between LIKE and IN? Here's the ...
0
votes
1answer
269 views

Modify output of custom loop using WP_query

I have a custom loop from a custom post type and I want to NOT display posts with the category 'slider'. I'm using this to set up the query: $args = array( 'post_type' => 'hotwives', ...
0
votes
1answer
292 views

Exclude categories and subcategories in QueryLoop

I want a QueryLoop that exclude some categories and its subcategories, I have this: $args = array( 'category__not_in' => array( 2, 6 ), ); this exclude the ...
6
votes
2answers
4k views

Getting Post Comments for post ID using WP_Query() and a Custom Loop?

(Moderator's note: The original title was "Is there a way to get post comments by post ID on a custom loop using WP-Query()?") Hi! I'm running a custom loop using WP_Query, that only displays one ...
0
votes
1answer
49 views

Help with Wp Query

I have a custom post type, and using wp query I am wanting to display posts only by authors with a specific role. How can I go about doing this?
1
vote
3answers
2k views

Way to include posts both with & without certain meta_key in args for wp_query?

EDIT 2: Rather than figuring out the real solution I've decided to use a workaround, and am simply setting the default value for book_in_series to '0'. Thanks to @eddiemoya for all his the time he ...