Skip to main content

Questions tagged [wp-query]

"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 global variable that holds the main query object prepared by WordPress based on a given request.

0 votes
0 answers
23 views

WP_Query filtering in ACF field containing dates

I'm trying to use WP_Query to filter Advanced Custom Fields posts that can contain this value in the "dates" field (text type), for example "20230101-20230102;20230201-20230202;20230301-...
jakr's user avatar
  • 1
0 votes
0 answers
47 views

How to short circuit a wordpress query that is not related to posts?

How to short circuit the below query via hooks such that the query is not run based on a condition? I tried using pre_get_posts filter but that is for posts queries only. The query runs as a part of ...
dc09's user avatar
  • 195
0 votes
0 answers
74 views

How to speed up WP_Posts_List_Table __construct() Query on a wordpress website with over 1 million posts?

On a website with over 1 million posts, the following from class WP_Posts_List_Table __construct() is taking a long time: SELECT COUNT( 1 ) FROM wp_posts WHERE post_type = 'shop_order' AND post_status ...
dc09's user avatar
  • 195
0 votes
1 answer
157 views

How WP determines archive page vs single page?

I have a confusion about how WP loop works on archive pages vs single post or page? when you request an archive url, it shows all the related posts with only title, excerpt etc. but when you request a ...
yucelm's user avatar
  • 3
0 votes
1 answer
19 views

WP Query filtering by custom category not showing all relevant posts

Here's a question I've been trying to solve all day: I added a WP Query that would show posts from a category that the admin chooses with a custom field. The post is a custom post type called "...
Jillian Hoenig's user avatar
0 votes
0 answers
25 views

Products are displayed only in the admin area

I have a code: $products_query_params = array( 'post_type' => 'product', 'product_cat' => 18, ); return new WP_Query($products_query_params); I need it to get products. But it works ...
Wembley's user avatar
0 votes
0 answers
56 views

Problems with relation OR in the meta query in WP_Query

The following WP_Query is executed immediately: $args = array( 'post_type' => 'post', 'post_status' => array('publish', 'private', 'draft'), 'posts_per_page' =>...
Matteo Feduzi's user avatar
0 votes
3 answers
57 views

Why is my nested 'OR' meta_query not working?

I have the following code which I think should work but obviously i'm missing something. Anyone who can tell why this is not correct? //EDIT Here is what needs to happen. 'Merk', 'Type' and 'Dummy' ...
Mart van der Kruis's user avatar
0 votes
0 answers
139 views

Applying a custom query for the AJAX "us_ajax_grid" function (from WPBakery)

I have some custom queries that are working properly with pagination if I use the regular pagination numbers, but I want to use the pagination as "page load on scroll" and then apply my ...
Pedro's user avatar
  • 33
0 votes
2 answers
104 views

Removing filename searches when searching attachments

My website's db is quite big. I have some 350,000 images in the media library (as well as some 350,000 posts). My wp_postmeta table has 4,580,552 rows. As a result, some queries are insanely slow and ...
Biranit Goren's user avatar
0 votes
1 answer
25 views

Check for a value in a custom query

I have a custom query to show people working in a specific division (label) in an organisation. I want to display the specific division’s name before the cards of the people are displayed. Currently I ...
Woohoo's user avatar
  • 1
0 votes
2 answers
27 views

Multiple meta value orderby clauses in a WP_Query

Is there a way to allow for multiple meta value orderby clauses in a WP Query? I have a query which retrieves records between meta keys start/end, and orders them ascending. I’m adding a new key for ...
commadelimited's user avatar
0 votes
0 answers
12 views

What is the best way to offset previous posts on the same page?

I have some main pages with multiple custom query like : all posts with filter X, all posts with filter Y, etc... I would like to make a last query for ALL posts, but exclude or offset all the posts ...
Gregory's user avatar
  • 582
2 votes
1 answer
136 views

Understanding the 'AND' Operator in WordPress WP_Query's tax_query

WP_Query is a very rich object but sometimes confusing. I want to know if these syntaxes mean exactly the same thing: bringing posts that belong on the same time to both categories 76 and 78 (...
AFA Med's user avatar
  • 183
1 vote
0 answers
10 views

Same query args showing different results order when setting different number of posts

This query using the same arguments is returning different posts order: sample / test codes: // Query 1 $query_args = [ 'post_type' => 'business', 'showposts' => 8, 'no_found_rows' =&...
FatMiming's user avatar

15 30 50 per page
1
3 4
5
6 7
384