"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
0answers
3 views

Expire posts with Pre and Posts Get new WP_Query in Categories

On my website I use Get Pre Post to display active posts (without an expiration date and those who are yet to expire), and also new WP_Query use to display only posts expired in each category page. ...
0
votes
0answers
12 views

Trying to get property of non-object in: $tag->slug

I suppose this is a very common propblem but. This function I was using was in fact not a problem until a couple days ago , that the debug starts showing this message: PHP Notice: Trying to get ...
1
vote
1answer
415 views

SQL query equivalent to WP User Query

I have the following WP user query code: //Get all users sorted by whatever $sorted_users = new WP_User_Query(array( 'orderby' => 'meta_value', 'meta_key' => 'satisfaction_rating', '...
0
votes
1answer
654 views

WP_Query post at custom position

Lets say I have a custom query which based on two custom post types: $wp_query = new WP_Query(array( 'post_type' => array('post-type-1', 'post-type-2'), 'post_status' => '...
0
votes
1answer
2k views

forming WP_Query for posts of all post types but from specific categories

I need to get post from blog, custom post type 1, custom post type 2. custom post type 3 and either from category 1 or category 2 or category 3 or category 4 or category 5 or category 6 or category 7 ...
0
votes
0answers
38 views

Order ascending is ignored in meta query?

I'm using pre_get_posts to alter my main query and attach a meta query to it. This is on a woocommerce products archive page (...not sure if that would make a difference). function has_upcoming_date(...
1
vote
1answer
1k views

ACF Relationship Field Search Filtering

I am trying to assign relate posts using the ACF relationship field. It has typeahead search to search by post titles. I would like to add meta_data search to the ACF relationship search. This ...
0
votes
1answer
27 views

DIsplaying URL of custom field in last post of certain taxonomy && post type

So, I need to echo the URL of a custom field from the last post published in a certain post type and with a particular taxonomy. This code so far works OK, but even that numberposts = 1, $...
1
vote
4answers
16k views

How to set posts per page using WP_Query()

I'm trying to set the number of posts_per_page dynamically using my own variable. This code works fine: query_posts( $query_string . "&posts_per_page=" . $myvar ) // then display the loop using ...
-1
votes
0answers
20 views

What is the one-query (or the fastest) way to get posts and their terms (more taxonomies)?

Now this might seem like a similar question One query to get posts and their taxonomy terms but it is just similar and does not have proper answer. Goal: I need to get limited number of posts and ...
0
votes
0answers
15 views

WP Meta Query at depth 2

I'm interested in doing a meta query according to some post data that doesn't exist at the first level of the post meta. In other words, I would need two or more keys to get to the variable I'm ...
0
votes
1answer
951 views

Displaying the category name of a custom post type

So I have a custom query, in which I'm displaying some results posts of a custom post type called "staff". This custom post type is linked to a custom taxonomy called "department". I am able to ...
0
votes
0answers
17 views

How to select N number of products and display it randomly in Woocommerce

I have a woocommerce setup with about 10,000 products, i would like to display all the latest products on the home page so that i can have N number of latest products from each PRODUC TAG displayed in ...
0
votes
2answers
2k views

Unable to combine “search value” and “tax_query” using WP_Query

This is my function in my template's functions.php. The problem is that this is working: function ajax_search_action_do(){ global $wp_query; $search = $_POST['search_value']; $country ...
0
votes
0answers
10 views

How to add OR condition in wordpress main seach box Query?

I'm trying to search from main search text box. Custom post type "course" and it custom taxonomy 'Location'. It I search with "USA", In data it looks for 's'= 'USA' AND 'loaction'='USA'. What I ...
0
votes
1answer
21 views

I want to get title name of post, but i didn't get by this code. Any suggestion?

add_shortcode('sort_featured_restaurant','sort_featured'); function sort_featured(){ $the_query = new WP_Query( $args ); // The Loop if ( $the_query->have_posts() ) { echo '<ul>'; ...
3
votes
2answers
201 views

Is it possible to orderby multiple meta_keys when using meta_value_num?

Reading through the order & orderby documentation, it's not clear to me whether there is any support to order based on multiple meta_key values. Obviously, using meta_query I can return posts ...
6
votes
3answers
2k views

Query Posts by Custom Field 'Price'

I'd like to display all posts within a given price range. For example: When a user inputs 100 and 1000 (in two separate form fields) - my site will display all posts that have a custom field called ...
1
vote
2answers
750 views

How to display future posts - modified query still yields 404

I have a very strange problem and I am stuck. I want the single page to display posts with the post_status of publish and future. So I added this code to my functions.php in my theme: function ...
0
votes
0answers
24 views

When will they make it possible to exclude post types from an wp_query?

Very simple, when I am setting up the arguments for an wp query, I can't exclude post types. While it is possible to include them, I would love to see an excluding possibility. Is there any ...
0
votes
1answer
19 views

Query events post type after current date and timezone

So I am making changes to a clients website and currently they have an events post type with some custom fields that allow them to set an events end date/time and the events timezone. The custom ...
0
votes
1answer
28 views

Is it possible to retrieve posts depending on meta_key LIKE condition?

I'm currently facing a little problem. I'm using ACF plugin which generate complex meta_key names when creating hierarchical fields. I found in my database meta_key named modules_1_content_0_module. ...
0
votes
1answer
42 views

Exclude current post from an array of posts?

I'm trying to exclude the current post from an array and I know that the codex says that it's not possible to combine post__in and post__not_in in the same query... But in wordpress everything (well, ...
7
votes
4answers
247 views

Is it possible to completely stop WP_Query retrieving posts?

I'm trying to use WP Redis to cache entire $wp_query object with key is $query_vars_hash. This is how $wp_query was added to $wp_object_cache: add_action('wp', function($wp) { if ( is_admin() ) ...
0
votes
1answer
23 views

WP_Query Custom Post Type if Category ID Equals

I've setup a custom post type "slides" and I've created two categories for the slides custom post type: "slides-testimonial" (id = 7) and "slides-regular" (id=8). I would like to run a single loop, ...
2
votes
1answer
895 views

Get Recent Posts by Date in Multisite

Everything in explanation is about CDTuts I've created a WordPress Network and I want is to get the recent posts from all of the selected subdomain blogs. I need to get the latest All organized by ...
0
votes
1answer
25 views

Only Get A Certain Number of Posts From WP_Query

I'm not sure what I'm doing wrong. None of my WP_Queries are returning the given number of posts. From what I can tell, it's returning all of them. How do I fix this? Here is the code I'm currently ...
4
votes
1answer
98 views

author.php with ACF and CPTs

As I write this, I'll do my best to avoid an XY Problem. What I'm trying to do: I'm trying to build an author.php template that: displays data from Advanced Custom Fields on the user's Profile ...
0
votes
2answers
2k views

Pagination doesn't work

I created myfile.php with the following content: global $paged; if ( get_query_var( 'paged' ) ) { $paged = get_query_var( 'paged' ); } else if ( get_query_var( 'page' ) ) { $paged = ...
1
vote
1answer
572 views

Too many posts cause slow load when paginating

I have about 10k posts and I made a page that lists all posts but it is paginated every 54posts. It gives 131 queries in 6.730 seconds which is pretty slow to load. Is there a way to make it load ...
0
votes
0answers
24 views

Wordpress Pagination archive/category [duplicate]

I have a problem with creating a simple pagination for the categories with WP_Query. I've got it to work for the archive, but if I try the same on the category template, then I get redirected to the ...
-1
votes
1answer
541 views

WP_Query - meta fields numeric

I'm having trouble with the code below. Attempting to do a query against meta data stored with the posts, in the mls post type. I think I know what the issue is, but not how to fix it. I am ...
0
votes
1answer
19 views

Object of class WP_Query could not be converted to int inside shortcode

I have the following code which is used to display download posts by the custom taxonomy. I am receiving the error Object of class WP_Query could not be converted to int When I have Query ...
0
votes
1answer
99 views

Adding a Theme Customizer Control for Posts_Per_Page

I am trying to add a Theme Customizer Control to change the number of posts shown in my WP_Query posts_per_page, like so... $posts_per_page_option = get_option( 'posts_per_page_option' ); $...
1
vote
1answer
3k views

Ajax load more posts - WP_Query parameters not working

I'm trying to replace the standard WP pagination with an Ajax load more posts button. I'm basically following the code from this question which for the most part works well. Here's the relevant code:...
1
vote
1answer
684 views

How to reduce the number of queries?

I have meta key "Due" for posts....if a post has expired (past the current date or not equal to it) then it will not be displayed in the count. This is my code, which works perfectly. My only problem ...
1
vote
1answer
982 views

Auto Populate Custom Field with Complex Value That Increase by One?

Can somebody help me to sort this? I am using WP 3.5.2 and I have "Orders" post type where purchase_order custom field is located. This is the sample of purchase order record: POCOS20130051 PO - ...
0
votes
2answers
40 views

display post multiple times based on array of dates

I have a custom post type for a simple schedule list and using the meta box plugin i have two meta boxes assigned to custom post type. 1 for an image and 1 for an array of date times . In my ...
0
votes
2answers
741 views

SQL returned by Wp_Query has wp_posts.ID = -1

I have a custom loop based on these arguments (below), and for some reason when it's run, the SQL returned has this fragment: ... AND wp_posts.ID = -1 ... And I get no results from the db. If I run ...
-1
votes
0answers
21 views

Pagination creating an extra page with no posts [duplicate]

I have a wp_query with the following $args: $time = current_time( 'timestamp' ); // Get current unix timestamp $cpt_posts_per_page = ( is_front_page() ) ? 4 : 8; $paged = (get_query_var('paged')) ? ...
0
votes
1answer
1k views

Group posts by meta_key

I have a Problem with grouping meta_values. The Query looks for posts with the meta key "company". I want a unique listing of the colors like: blue red yellow array_unique was not successful and also ...
9
votes
2answers
111 views

Wordpress retrieving meta data for all custom post types in list view

Im having an issue in WP where php is dying, ive increased memory but the process jumps to 100% cpu usage then dies and apache throws a 500 error. Ive tried to get apache to log something, or php / ...
1
vote
3answers
104 views

new WP_Query() - what is the earliest valid hook?

Specifically, is it valid to run a new WP_Query() during the plugins_loaded action?
2
votes
2answers
843 views

Pagination problem after WP_Query with tag filtering

I have a problem with a custom WP_Query. I want a page with all posts with a specific tag. This is the code I'm using: <?php //save old query $temp = $wp_query; //clear $wp_query; $wp_query= ...
0
votes
0answers
23 views

How to use get_posts on a secondary loop [on hold]

I feel like I am missing something terribly obvious. I have set up my secondary loop and it returns the_title() and the_post_thumbnail() as expected, but I am also using the Advanced Custom Fields ...
0
votes
3answers
2k views

Pagination not working on Custom Page Template

I searched a lot on this but I can't figure out why my code is not working. I published a page with slug "blog" that uses a custom built template "page-blog.php" that I build from editing the ...
0
votes
2answers
419 views

Custom loop of a single category, cannot order by date. What am I missing?

I'm going nuts. All I have is a simple loop on the home page of the site (which is a static page), and it should show the most recent (1) post of a certain category. The trouble is no matter what i ...
0
votes
0answers
31 views

Display most popular in the past two days

Hi I'm using this code below to display the most popular post on my wordpress site. It works great! I was wondering if there was anyway to show the most popular post of the current day? This in my ...
0
votes
1answer
41 views

How to fix pagination for custom loops on front-page.php

A search on this topic on this site throws up a lot of results claiming to have resolved this issue, but I am having a contrary experience after implementing these guidelines as outlined here: How ...
6
votes
1answer
60 views

How to remove_query_arg() for paginate_links()

I implemented a pagination using paginate_links() like below: <?php function wpse229670_pagination( $query = false ) { global $wp_query; $query = $query ? $query : $wp_query; $...