"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

5
votes
2answers
2k views

How to do a wp_query using “BETWEEN” with two meta_values?

I'm starting with Wordpress, already achieved some queries, but this one... ugh! It's being a pain to me! What i want to do is this part of query: " ... WHERE "VALUE_THAT_I_WANT" BETWEEN ...
0
votes
1answer
476 views

Shortcode does not display pagination [duplicate]

I use a normal page for display posts by a shortcode.On pages posts are displayed correctly,but doesn't echo the next and previous posts links and the page content is displayed below shortcode ...
1
vote
1answer
384 views

Most commented last 24h, week, month, year and all time - posts_where

I've removed my old post here, as the posts_where method is outdated. Thanks to kaiser, this is now how easy it is to list most commented posts within a certain time span: <?php $popular = new ...
0
votes
1answer
153 views

Including 'cat' => $cat breaks meta_query

so, i have a custom loop that seems to be working everywhere but one place. $args = array( 'post_type' => 'post', 'meta_key' => 'wpcf-post-weight', 'orderby' => ...
0
votes
1answer
17 views

function wp() does not use meta_query?

I found that the $wp_query variable is populated by wp() function. I would like to filter my results using the WP_Query options. What I want to do is wp(array("meta_key" => "key", "meta_value" ...
0
votes
1answer
102 views

Wordpress WP_Query compare not working?

There are my arguments for my custom WP_Query. $args = array( 'post_type' => 'post', 'posts_per_page' => '9', 'name'=>'Products', 'compare'=>'LIKE' ); $the_query = new ...
0
votes
0answers
344 views

Wordpress query fire inner join in one table 5 times?

Dear friends this is my arguments for WP_Query. $args = array('post_type' => 'job_listing', 'relation' => 'OR', 'meta_query' => array( 'relation' => 'OR', array( ...
1
vote
1answer
250 views

pagenavi with merged wp_query [duplicate]

i need to use wp_query to excute posts from 2 separated keywords using s=keyword so i have found this answer & it is very very useful Combining queries with different arguments per post type ...
0
votes
1answer
36 views

Search for pages with permalink

I'm searching for posts this way $args = array( 'name' => $permalink, 'post_type' => 'page', 'post_status' => 'publish', 'posts_per_page' => 1 ); $posts = get_posts( $args ); ...
0
votes
1answer
126 views

assign 2 $args to one wp_query

i need to excute posts from 2 search keywords & put all in one loop to showing by using WP-Query i have trying array_merge but this not worked for me so my last code is: please note: i need to ...
0
votes
1answer
2k views

wp query by search in titles only & put the posts in loop

i need to get posts by search in posts title only not search in full post & put the posts in loop to show it in a slider Note : i need to get posts by keyword in title & put it in loop to ...
1
vote
1answer
58 views

Query Posts but only return 1 from a custom taxonomy?

I want to query my posts and only return one post from a custom taxonomy. Is this possible? Here is an example: I have a custom taxonomy called Author. I have 200 posts with various authors. I want ...
0
votes
1answer
37 views

WP Query / Meta Query [duplicate]

How can I use a meta query like this: >>>>>> KEY_X Conditional IS ABSOLUTELY REQUIRED <<<<<<<<<< array( 'key' => ...
0
votes
2answers
104 views

Pagination With Custom WP Query not functioning

I have the following custom query and im attempting to paginate the links of previous archive posts using the example from the wordpress codex ...
0
votes
1answer
107 views

wp_query conditionally get posts

My wp_query gets posts starting at the 5th one, proceeding it is another loop for the first four, for styling reasons. How do I conditionally get the wrapper for these posts only if they exist? The ...
1
vote
0answers
60 views

How to get the post terms from a child taxonomy

I have the following code that gets the slug of the taxonomy "author" from a custom post type "books" and gets the post from another custom post type "authors" that has the same slug. <?php ...
0
votes
1answer
170 views

How return normal search result using wp_ajax action for wordpress

I want the normal search result to be available when using the wp_ajax action. Is there a way to do execute the normal WP_Query for the parameters that are available in the current request? This is ...
1
vote
1answer
42 views

Can I use OR relation for one item when calling tax_query from WP_Query and use AND for the rest?

I am trying to refine search in wordpress template. Basically I want to use multiselect with . I am using array to store selected options like this: location[]=term1&location[]=term2 etc etc. This ...
0
votes
1answer
60 views

Wordpress multi-query not returning as expected

I am trying to perform a merged query to get at most 6 posts from either the post post type and my events custom post type. The post query is based off of whether or not the Featured Image is set, and ...
0
votes
1answer
713 views

Register Taxonomy - What is `query_var`?

The Codex doesn't really explain it very well, what is it used for and how do I use it exactly?
0
votes
0answers
137 views

Trying to combine multiple Wordpress queries

I am trying to query multiple post types and meta values in Wordpress... the query is trying to fetch event post types with a featured meta key, as well as post post types with the featured image set. ...
1
vote
0answers
84 views

Query posts and return XML

Here is the short and sweet of what I am hoping to do. I would like to have a way for external websites to query mine using a game title and they would get an XML back that contains the text of the ...
0
votes
0answers
232 views

Join two wp_query

So, i have custom posts with this settings: Example 1: have meta_key "price" Example 2: have meta_key "no_price" So, i want to list this posts ordered by "price". I just want to join these two wp ...
0
votes
1answer
478 views

Insert images into wordpress post with a query

I have a Wordpress installation with 2.000 posts. Also in a separate table of my database I have a set of image paths and the filenames of the images, each image is assigned to each post of my ...
0
votes
2answers
489 views

wp_query not returning my custom post

I am using these helper classes to create a custom post but wp_query does not return any instances. Checked the source and as far as I can see the public has been set to true. The query is the ...
1
vote
1answer
83 views

How do I run through a Wordpress loop called from a filter function?

So I'm trying to populate an Advanced Custom Fields selectbox with a nice complicated array based off some post data. I've been trying to do this by doing a custom query and loop through the returned ...
1
vote
2answers
71 views

Querying Term Posts in Loop

I'm trying to show my CPT Category along with any posts associated with it below the title. I have the first loop fine: <?php $cats = get_categories(array('taxonomy' => 'custtax', 'orderby' ...
0
votes
1answer
195 views

WP Query Post Type with same Taxonomy name

This is what I have: Custom Post type "Books" with Taxononies/Categories "Genre" and "Author" Another Custom Post Type "Authors" which have all author pictures and bios. This is what I want to do: ...
0
votes
0answers
38 views

WP Query Wordpress Post Type with the same Taxonomy name

This is what I have: Custom Post type "Books" with Taxononies/Categories "Genre" and "Author" Another Custom Post Type "Authors" which have all author pictures and bios. This is what I want to do: ...
4
votes
2answers
324 views

replace the WP_Query class in the main query

For a project I needed to heavily modify the behavior of WP_Query. So what I did was extending WP_Query basically like this: class eacf_shared_query extends \WP_Query { function query( $query ) ...
0
votes
1answer
276 views

Custom Page Template Category loop not functioning correctly

So after several attempts to correct this - It seems the pages not load but don't pull in the correct posts from each category. It just seems to pull in the same default posts whenever I click each ...
0
votes
1answer
269 views

How to get specific post meta by title or id

I have register bellow custom post type in function.php and I am using Advanced Custom Fields. Using advance custom field type I have added one image field and assigned to my Release custom post type. ...
0
votes
1answer
141 views

Don't repeat posts from children in parent taxonomy query

I have a query on a page and I want to prevent it from returning posts in the parent term that have one of the child terms of the parent. For example: Parent 1 Child 1 Post 1 Post 2 NOT Parent ...
0
votes
1answer
199 views

Meta Query for specific months

I have a custom field which stores a date in a timestamp. I want to run a query that display posts based on the month, for example all entries from March, the specific day or year doesn't matter. I'm ...
0
votes
0answers
120 views

Update Post with Modified Data

Task is to take class from <pre class="php"></pre>, and add that class to <code></code> and wrap all content of <pre> into <code> after that. I am querying WP with ...
1
vote
1answer
99 views

if/else on custom query gives 200 OK when condition not met?

What? I am modifying my theme to show comments of a post on a separate page. How? Mostly based on this answer but with improved checks and code. So this is what my page-comments.php (kinda) looks ...
0
votes
2answers
75 views

meta_query compare not doing what I want it to do

I'm trying to run a query that only shows posts if it's meta value has a date string that is LESS than the current date's string. An example is below; <?php $current = date('Ymd'); // Eg: ...
1
vote
3answers
2k views

How do I get a meta value from WP_Query?

I've got the custom post type foo with meta fields called bar and baz. Now I get the WP_Query object using: $args = array( 'post_type' => 'foo', 'meta_key' => 'bar', ...
0
votes
1answer
779 views

date_query seems to be ignored by wp_query

I'm altering my main wp_query in a pre_get_posts filter in order to improve my site search capabilities. I've successfully achieved searching in taxonomies, but I fail when it comes to the post date ...
0
votes
1answer
274 views

Get Post ID as a separate RSS feed item

I am looking for a way to display or echo each post ID within my RSS feed. Basically when I access my RSS feed site, I get the following XML items: <title>, <link>, <comments>, ...
4
votes
1answer
14k views

How to store and receive variables in WP sessions?

I have a form with some checkboxes and inputboxes selectboxes and it shows what the user wants via an ajax call. The problem is that when the user click on the item and the detail page is shown and ...
6
votes
4answers
2k views

Best way to detect if you are in a SINGLE POST page

So this may seem like a pretty menial thing, but follow me here. I'm trying to add some logic through the pre_get_posts action. This is the entire WP_Query object given to me. (see the end) Things I ...
0
votes
1answer
98 views

Manipulating a query

I'm trying to use my own search form rather than default single-field form. So I made my fields and set the values to the query by using pre_get_posts hook. All things are well. Because of searching ...
0
votes
1answer
346 views

Compare WP Custom Field date

I had create a custom field "date" with this format 16/09/2013 (d/m/Y). How can i compare date and show only post with date from today ? This is my query that don't work !! $args = array( ...
0
votes
1answer
156 views

How to Order Posts by Custom Fields?

Can someone tell me why this is not working: $args = array( 'cat' => '2,39,30', 'orderby' => 'title', 'order' => 'ASC', 'orderby' => 'meta_value_num', 'meta_key' ...
2
votes
1answer
450 views

Transient caching for wp query

I read about transient in the codex and some questions and answers here. So i'm developing a web app based on wp. It works now, but i want to optimize it. Users manage content regulary, so crud ...
0
votes
1answer
540 views

Get latest author posts inside the loop

I have a wordpress theme which needs to retrieve the latest 3 author posts which is simply straight forward but I have ran into a sticky problem. Because I am calling this from already within the: ...
1
vote
1answer
227 views

How to query for posts without a post_format

I have looked in the WP codex for an example which shows how to use a taxonomy query to retrieve a set of posts that have no post_format. IOW: 'All posts where an aside or quote or link...etc... ...
0
votes
1answer
67 views

Toolbar Hidden in a Virtual Page

I am trying to create a virtual page, but my admin toolbar is not showing up. This is how I am creating the virtual page: functions.php add_action('init', function() { ...
1
vote
2answers
726 views

How to optimize multiple WP_Query() calls on one page?

The current site I'm building has a homepage that is going to have around 10 instances of WP_Query(). Some of them are going to pull a series of posts, while others are targeted at one single post ...