"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
1answer
2k views

WP_Query class not found

The idea is simple. I have a drop-down menu generated with get_categories(). This outputs a list of categories in an unordered list, each in it's own li element. I'm getting the text values of those ...
2
votes
1answer
3k views

Can I query custom meta data through WP_Query

Ok, my question is a bit complex so I will try and give a general explanation and then go into details afterward. I am running WordPress 3.4.2 and I am using WCK Post Type Creator and WCK Custom ...
1
vote
0answers
317 views

How to filter a query by multiple meta keys and order by other meta keys

I'm trying to query posts using WP_Query and meta_query parameters: $args = array( 'post_type' => 'produkty', 'meta_query' => array( 'relation' => 'AND', array( ...
0
votes
1answer
178 views

Pagination in custom query not working [duplicate]

hi im trying to output pagination without any success. below is my code in a page-products.php template <?php $products_query = new WP_Query(array( 'post_type' => 'product', ...
0
votes
1answer
66 views

Order by meta values

I have 3 meta fields related to dates: year = 2012 release_date = 14 November 2012 release_date_db = 20121114 I need to show the posts from year 2012 sorted by release_date. I made this: ...
1
vote
1answer
202 views

Is there a reason why Pages are not publicly_queryable?

I am building a segmented search (by post type) with the ability to filter to a specific post type and realized pages were not publicly queryable. What I know I can do is the following: function ...
1
vote
1answer
244 views

WP_Query() and get_posts() can't handle over a thousand posts?

So I have a search function that just fetch custom posts and return them as a list. function search() { // post query args $args = array( 'post_type' => 'post_type', ...
0
votes
1answer
1k views

sort and display posts by custom field (wp-query and the loop))

i only want to show upcoming events posts on the homepage. i have made a custom field using the 'custom field suite' plugin, called 'ENDS' representing the date an event ends. as you can tell, i ...
0
votes
1answer
1k views

meta_query with array as value

I am writing some PHP which allows users of my site to submit a form and query posts by their post_meta. Everything works fine except for one thing, I used Advanced Custom Fields to create the ...
0
votes
2answers
72 views

how to retrieve WP_Query without ordering by date [duplicate]

Possible Duplicate: Orderby = none not working I want to use $query = new WP_Query( 'post__in' => array( 2, 5, 12, 14, 20 ) ) ); to retrieve posts by ID, I do and the result ordered by ...
0
votes
2answers
1k views

How to get post meta value and post in one query?

When query a post, I need not only the post but also the post_meta. But seems the post query and meta query can not be done together. With WP_Query, I first get the posts, then, I need to do ...
0
votes
1answer
940 views

Duplicate posts showing up in loop using infinite scroll

I'm experiencing an odd issue using Infinite Scroll for the WP_Query loop on my homepage. Half the time when the second page fires, I'm getting a few duplicate posts showing up in the second set. I ...
3
votes
1answer
336 views

How to Access Global $multipage or Global $numpages outside the loop?

I am writing a code in the header that pertains to link rel='prev' and link rel='next' thing but I need to check if the post is multipage. I check out these global variables: $numpages $multipage ...
1
vote
1answer
153 views

How to disable main query?

I don't use The Loop, because I use different queries to fetch posts (I use 3 queries instead of one). How to disable main query for home, category and search pages?
0
votes
1answer
805 views

get_query_var returns null

My pretty permalink clearly shows the query_var: localhost/site/?tree=312 Yet when I run var_dump(get_query_var('tree')); I get NULL returned. Any reason why? Also when I print_r($wp_query), I ...
1
vote
2answers
219 views

Having a Function Inside of the Loop

I am trying to make a frontend product editor for WooCommerce, and have a loop that returns all of the products for the current user. I am trying to use gravity forms as the editor, so a single ...
-2
votes
1answer
139 views

Get all user with both meta_value

I was wondering if there were any efficient way of fetching all user comparing two different meta_key. I am currently fetching all user compared to the first meta, then loop trough the user_id to ...
2
votes
3answers
598 views

WP_Query can't exclude more than 1 author?

It seem wp_query have the problem where it does not accept more than 1 negative value in author argument. for example: $args = array('author=-2,-3,-4'); $newquery = WP_Query($args); This grab ...
1
vote
1answer
81 views

How can I query posts with newly uploaded images?

I have a custom post type for events. A couple of days after each event photos are sometimes uploaded and attached to the event they were taken at. I want to highlight these image gallerys somewhere ...
1
vote
1answer
317 views

Filter posts with meta_query NOT IN where value has multiple values

I would like to use a meta_key to store multiple values in that key. Thereafter, I would like to filter away posts that do not contain a specific value in the key. In other words, just show posts ...
0
votes
1answer
150 views

Custom post-type custom query - show all posts

I've got a taxonomy archive to show custom post-types, its got a custom query calling the posts - I can't figure out where to put showposts in it. global $wp_query; $term = get_term_by( 'slug', ...
2
votes
1answer
3k views

Multiple orderby values in WP_Query

I'm trying to come up with a query to sort by multiple orderby values. Here's what I have so far: $dept_id=2; $query=new WP_Query(array( 'post_type'=>'wpcontactus', ...
0
votes
1answer
982 views

get_posts not finding argument: post_name

I am digging up posts with a specific slug: Where $postSlug = 'abc' $args = array( 'post_name' => $postSlug, 'post_type' => 'post', 'post_status' => 'publish' ...
-1
votes
1answer
97 views

WP Query Obj: Set value to be unequal | Hide media by admin

I would like to hide all media uploaded by the admin. I've found an answer to this question to be pretty close. Except that the query returns all media uploaded by a specific (current) user, instead ...
0
votes
1answer
74 views

What triggers these wordpress queries on my homepage?

I am trying to clean up my wordpress theme and I want to know what triggers the following questions on my blog homepage. First - do I need this on my homepage?: SELECT user_id, meta_key, meta_value ...
-1
votes
2answers
373 views

First post outside of loop, homepage only?

Because of the way my templates are structured, I need to pull the first/sticky post from the site outside of the standard loop, just on the homepage. I'm using _s (underscores.me) as a base, so the ...
3
votes
1answer
459 views

Excluding a custom taxonomy term breaks wp_get_post_terms

I'm trying to exclude one custom taxonomy from an archive page, and then show the terms of the returned posts. When I run WP_Query to exclude the custom term, it returns the posts correctly, but no ...
1
vote
1answer
893 views

search query within custom taxonomy term, post title and meta field

I want to create a search that does: Search within my custom taxonomy - custom-tags search the post title search select meta field ?? dont know search with custom post type - easy part I looked ...
0
votes
3answers
4k views

Exclude post ID from wp_query

How can I exclude one specific post from a WP_Query query? (For example, show all posts apart from a post with the ID 278) I've tried the post__not_in argument but it just removes all posts.. Any ...
-1
votes
1answer
181 views

How to sort by post_date and meta_value_num?

On a page, I want to display content from four areas, posts and three custom post types, and sort them all by date. The post date is post_date and the cpt dates are meta_value values called, for ...
1
vote
0answers
533 views

Display one post from each term in a custom taxonomy

I am trying to display a list which shows one post (and information about the person posting) from each custom taxonomy term. The code I am using is as follows, but it is instead printing out EVERY ...
1
vote
1answer
204 views

reducing the amount of wp_query calls

I'm working on a site where we're introducing drop down panels from the menu which will display thumbnails from various tags on the site. Each panel has a left column displaying a featured post, and ...
0
votes
1answer
228 views

Select posts that match multiple category names, must match all categories listed

I need to search for posts that belong to multiple categories, but they must match all categories listed, as in if I list category names 'japanese' and 'dessert' the matching posts need to be in both ...
0
votes
2answers
502 views

How to apply pre_get_posts to a custom query?

How can I apply pre_get_posts to a custom query? For example, if I have: $custom_query = new WP_Query(...) //code here How can I apply the pre_get_posts for this $custom_query?
0
votes
2answers
143 views

Pagination stops at page 6

The loop below works fine, apart from the fact that the pagination will always stop on page 6. No matter what arguments i specify, it will never show more than 6 pages. Does anyone know why? ...
1
vote
1answer
67 views

How to list posts with disabled/closed comments, with pagination?

i'm interested how to display all posts (from all categories) that have closed/disabled comments? I have tried using the comments_open() function inside the loop, that works, i don't know how to ...
1
vote
2answers
273 views

How to add terms to my tax_query based off of the current post

I need the terms in my tax_query to be the ones from the current post. I am trying to this by using a variable. The value of the variable is given by using the get_terms() function. The problem is ...
1
vote
0answers
65 views

Display posts with comments closed, with pagination?

i'm using a custom query, which needs to display all posts with closed comments. I have this <?php $the_query = new WP_Query('showposts=-1'); ?> <?php while ($the_query -> have_posts()) ...
0
votes
2answers
167 views

Providing a function to override the default query

In a plugin, I want to provide a function for users to set the default query in their templates, so they can use some custom loops. What would be the best way of doing it? I imagine something like ...
0
votes
1answer
336 views

WP_QUERY tax_query not working

$query_args = array( 'cat' => $lesson_id, 'meta_value' => $lesson_type, 'post__not_in' => array($current_post_id), 'tax_query' => array( array( ...
1
vote
0answers
74 views

can these 3 queries be re-written as 1 query?

I am creating a Dentist directory site, and I have a taxonomy archive page which requires particular grouping and sorting (see below). So far I have only been able to achieve this using 3 WP_Querys ...
3
votes
1answer
2k views

Merging multiple wp_query objects

I have the code below for a multisite install. It works fine, but I need to merge each WP_Query loop object from each multisite together for use in another template with the WordPress loop. Is this ...
3
votes
2answers
2k views

Why is WP_Query not working with category_name?

Why on earth is this piece of code not working? $my_query = new WP_Query('category_name=feature'); while ($my_query->have_posts()) : $my_query->the_post(); echo 'test'; ...
0
votes
1answer
164 views

Querying meta values within an array

Okay so I'm using the relationship field from Advanced Custom Fields against a custom post type. The relationship lists countries, when these are saved they are within a serialised array: [country] ...
0
votes
4answers
319 views

Pagination doesn't work for home page custom post type query

I've spent hours trying to figure this out, tried TONS of different methods and all failed in their own way. What I'm trying to do: Limit home page custom post types (woo_estate) to 6 and then ...
0
votes
2answers
261 views

get_the_terms - but only show 4 Posts

I am using this code to load related posts with a custom taxonomy term slug: <?php global $post; $terms = get_the_terms( $post->ID , 'topics', 'string'); $do_not_duplicate[] = $post->ID; ...
1
vote
1answer
898 views

How to get a meta value from all post

I searched for a while but I didn't find any solution. I used the functions listed here. It outputs something like this: Array ( [0] => 15 [1] => 30 [2] => 50 ) But I want ...
0
votes
2answers
818 views

How to get single post by one author?

I just want to get the most latest posts by an author. I am using get_posts at the moment but I notice it doesn't take an author argument, so how I can I specify my author? $args = array( ...
0
votes
1answer
371 views

Retrieving meta-box from a custom-post-type

I am trying to display data from a custom post type on my home page, for which I am using a separate template. I'm getting a Fatal error: Call to undefined method WP_Query::have_post() when my code ...
1
vote
1answer
181 views

Add inline HTML to posts published within last 24hrs

Basically I'm looking to add this line of code to posts published within the last 24hrs: <span class="new">New!</span> When the post is over 24hrs old, remove the inline HTML element. ...