"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
85 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(); ...
0
votes
2answers
2k views

Can't get drafts with WP_Query using post_status parameter

I can't seem to get drafts to show up with WP_Query, even when post_status is set to 'any' or 'draft' $args = array( 'p' => 1234, 'post_type' => ...
0
votes
1answer
761 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
201 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
2answers
305 views

How to sort by most watched in X days/months

So I managed to loop my posts in a page template, ordering the posts by most viewed. The query posts string looks like this $wplover_home = new ...
0
votes
1answer
77 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' ...
1
vote
2answers
639 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' ...
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
464 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
181 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
2answers
276 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
986 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
5k 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
607 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
470 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
123 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 ...
0
votes
1answer
2k 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
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 ...
3
votes
2answers
1k views

Does Wordpress generate an automatic page for post formats?

I want a page to view only a specific post format (e.g. aside). Do I have to create my own page and run a custom query, or does Wordpress have an automatic page generated for me (like the ...
4
votes
1answer
396 views

Query causing load because of SQL_CALC_FOUND_ROWS post counting?

I found this query causing some load in the server, my hosting provdier asked me to look on it. SELECT SQL_CALC_FOUND_ROWS wp_posts I think this select no. rows found in wp_posts table.. but i ...
4
votes
4answers
6k views

Sorting a query by custom field date

EDIT: Reworded the question for more clarity I'm trying to sort by custom meta box data, which I am converting to a date using the strtotime function, but I'm having some difficulty. My chief ...
3
votes
2answers
452 views

What could be causing my wp_query pagination to break?

I'm using categories and wp_query to create an "advanced search" feature on my website. It was working great until recently I noticed that the pagination was broken. The following 2 links should ...
0
votes
1answer
1k views

How to Get All Posts but the Private ones?

I am creating a frontend mosaic view where i need to show the most recent posts. So i need to show all published posts to every visitor, but keep the private ones for the logged in users. I know how ...
0
votes
1answer
1k 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
288 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
343 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 ...
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?
0
votes
2answers
798 views

Customising wordpress search and using $_GET[“s”]

My theme's search.php currently has a few "IF" statements to deal with the different types of search that my website uses. I have a site-wide search, a species (custom post type) specific search and ...
0
votes
1answer
308 views

What's wrong with this wpdb query?

I want to select some tags with the same term_group, I tested it in phpadmin, the query get the correct result, but once add $wpdb flavor, it returns an empty array. Any advice? $primary_tag_id = // ...
1
vote
1answer
469 views

Paginated HTML Sitemap

I've got to the point where I needed to break down my HTML Sitemap into several pages. It contained 2000+ links. The big layout was showing all post titles under category names on one page. I decided ...
0
votes
2answers
214 views

How to order by multiple date meta_values?

I am trying to find some way when using WP_Query of ordering by multiple meta_values. I know I can order by multiple values and I know how to order by meta_values but I cant seem to figure out how to ...
2
votes
1answer
2k views

order by numeric value for meta value

I have read countless posts on ordering data by numeric value ( as opposed to string - it i have a numeric meta value and it gets ordered like this 1 11 12 2 233 etc as opposed to the way i want it I ...
3
votes
1answer
291 views

Query two taxonomies via URL or link?

I've been banging my head about this, and have created a work-around, but it would be much nicer for my site's organisation if I could figure this out. I want to be able to query posts across two ...
1
vote
1answer
1k views

Sanitizing search data for use with WP_Query

I'm using heavily-customised WordPress to drive a fishkeeping website. I have two separate search areas: a site-wide search and a fish species search. The latter also has advanced search features ...
1
vote
1answer
441 views

Wordpress: Display posts by custom select query

I need Wp_query with two custom fields, one custom field for orderby and another: (if this key exists in the post so show the post else dont add this post to query.) I tried like this but doesnt ...
0
votes
1answer
395 views

Does using a custom query_var create a security hole?

Say I put the following code in functions.php function add_my_query_vars($qvars) { $qvars[] = "new_var"; return $qvars; } add_filter('query_vars', 'add_my_query_vars'); If somebody requests ...
0
votes
1answer
377 views

How to stack name list in non-alphabetical order?

an update on this: I managed to change from 'orderby'=>'title' to 'orderby'=>'date'as suggested. This almost made the order perfect except one clarinet that falls out of the order and is placed in ...
1
vote
1answer
588 views

Update Loop with Form

I have a photo gallery I'm developing using WP as a means for content management. I'm relying heavily on some jQuery plugins to manage the UI styling and manipulation (via sorting). My problem is ...
1
vote
1answer
2k views

WP_Query last five posts, simply ordered by meta_value

I can't believe I'm asking this question. It feels like such a simple method, yet I've poured over the WP pages and dozens of similar questions to no avail, so here it is... I've got a WP_Query with ...
0
votes
1answer
252 views

My class function is not seeing GET url paramaters

I have a set of variable set up, created with add_filter in my plugin functions file: add_filter('query_vars', 'user_country_var' ); add_filter('query_vars', 'user_lat_var' ); ...
2
votes
2answers
2k views

Get posts by meta data OR title

I have a working query that calls all my posts that have a certain meta value for one of two meta keys: $term = $_GET['term']; $args = array( 'post_type' => 'some_cpt_name', 'meta_query' ...
3
votes
1answer
6k views

Group WP_Query by category

OK, here's my setup: Custom post type called "issues" (for a magazine) Posts with custom meta field matching the post ID of the corresponding issue. When I'm on a single "issue" post page, I want to ...
-1
votes
1answer
111 views

294 Queries on Mainpage of Wordpress

I have 294 queries on my wordpress site. I checked using sql monitorand the maximum queries are to display count of a cities list custom field. Lets say there are 200 cities then 200 queries are ...
0
votes
1answer
59 views

Wrapping x posts in html without leaving empty html

So I'm trying to spit out unlimited numbers of posts for this wp_query, 6 at a time, each one being wrapped in <dd> so that it functions with my jQuery slider. The problem is, if I have exactly ...
1
vote
1answer
4k views

Getting all user metadata from user

I am trying to show bio and other custom metadata for my users in a page. So, i want to query the user metadata table for it. I have tried but did not find any functions for that. What i am looking ...
1
vote
2answers
2k views

Exclude the parent custom post-type posts only

Not sure if this is possible without some form of hard-coding but I have a custom post-type called 'city'. Within the 'city' post-type I have some parent post (e.g. England, America and China) and ...
1
vote
1answer
658 views

AJAX search posts and pages

Im trying to make a plugin where i need to create an AJAX search. Im using the method described in http://www.garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress/ to perform the ajax calls. So far ...
-1
votes
1answer
1k views

Getting Custom Field value in WP_Query

i am trying to display first post of 3 categs on my index page. so for that i wrote a little function as follows: function excateg($categ) { $recent = new WP_Query("cat=$categ&showposts=1"); ...
-1
votes
1answer
585 views

Query_vars not working for me

I'm trying to add an all pages link to posts when I have ?all=1 at the end of the URL it's returning "not set", I'm not sure what I'm doing wrong. I've looked here and my code is the same as here: ...
0
votes
1answer
131 views

Inefficient Query Confusion

Edit #3 - meta_keys as an array This seems to compare more than just the "opening_time" I can set the opening time for the wrong date or even leave it blank and it will still grab a post if the ...