"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

1
vote
1answer
143 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
708 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
192 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
533 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
304 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
144 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
2k 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
902 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
93 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
73 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
355 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 ...
2
votes
1answer
405 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
844 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
179 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
491 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
195 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
218 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
489 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
137 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
64 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
261 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
63 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
156 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
328 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
159 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
307 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
253 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
850 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
791 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
343 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
178 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
107 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
281 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
267 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
2k 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' ...
1
vote
1answer
417 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
520 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
924 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
80 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 ...
0
votes
2answers
2k views

Display one latest post from multiple categories

This should be very easy, however for some reason I can't find a working snippet anywhere on the web.. I basically need to display one latest post from 6 categories (can be changed to 7,8, etc etc) ...
0
votes
2answers
699 views

Pagination only won't work in author template

I using custom $wp_query for most of my archive pages like, taxonomy,index,category and author page. Everything working fine, except one weird thing - the author template page pagination failed to ...
0
votes
2answers
68 views

Query is not work

I use this codes in my functions.php to track post views. /* Functions to track Post Views*/ function getPostViews($postID){ $count_key = 'post_views'; $count = get_post_meta($postID, $count_key, ...
0
votes
1answer
224 views

Start Query from 2nd Post without offset

is there a quick and easy way to load all the posts, starting with the second post and making the first post the last post? If I use offset, I then lose the first post, but I don't want to lose it, I ...
2
votes
1answer
479 views

WP_Query not looking at child category

Hi all I have a loop that shows a post on a single page and puts the first category name in the variable $cat: $cat = $category[0]->cat_name;?> Now after the post I have a link to show ...