"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

2
votes
1answer
3k 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
84 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 ...
1
vote
2answers
2k 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
2k 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
579 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 ...
2
votes
1answer
224 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
1k 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
541 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
151 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
1k 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
82 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 ...
2
votes
1answer
381 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
178 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
2answers
5k 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
2k 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
134 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
79 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
537 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
679 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
2answers
1k 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 ...
2
votes
3answers
11k 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
191 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 ...
2
votes
0answers
706 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
227 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
297 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
724 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?
1
vote
2answers
190 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
75 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
413 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
70 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
262 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
389 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
78 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
3k 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
4k 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
207 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
334 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
328 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
2k 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
944 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
517 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
214 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. ...
0
votes
1answer
134 views

Query Custom Post Type by Tag

Kinda confused on this.. hoping someone can help. I have custom post type named "Providers" that I want to pull entries from that are tagged "highlighted". I enabled tag support on the custom post ...
2
votes
2answers
389 views

Splitting the main query in multiple loops with query_posts and/or pre_get_posts?

I have a custom post type 'events', to which I have associated a custom taxonomy 'calendar'. The calendar has 12 fixed terms, for each month of the year ( 'august', 'october', 'november, etc.). I'm ...
1
vote
1answer
413 views

using new WP_Query in save_post function alters $post

I'm trying to include a WP_Query in a save_post function for a custom post type. The query is used to check all the other posts for a custom field bh_shortcode to make sure the content of the field is ...
3
votes
2answers
4k views

Custom Post Type, WP_Query and 'orderby'

I do have a custom post type with the following setup: $supports = array( 'title' , 'editor' , 'thumbnail' , 'revisions' , 'page-attributes' ); $args = array( 'hierarchical' ...
2
votes
1answer
815 views

Secondary Sort (fallback) for WP_Query

What I'm after is creating a secondary (or default) orderby option for a custom query. Here is what I have: $post_args = array( 'post_type' => $taxfunc_post_type, 'meta_key' => ...
1
vote
1answer
683 views

Advanced search form with filters for custom taxonomies

I'm trying to build a complex search form with filters for several custom taxonomies, a search terms input and a select for the number of items displayed / page. The question has been posted before ...
0
votes
1answer
1k views

How to get latest post excerpt from a specific category?

I'm working on a theme homepage and would like to include an excerpt from the latest post in a specific category. In this case, the category slug is "gear". I've tried a couple options with WP_Query ...
0
votes
1answer
85 views

Which is from this queries is more faster

I need to do some query. Now i choosing from this variables. Which is from this queries is more faster. Which differences between them ? function filter_where($where = '') { $where .= " AND ...