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.

Filter by
Sorted by
Tagged with
0
votes
0answers
13 views

Improve wp query perfomance on large db

I have 100000 records in my database and so many meta query performed on it so it takes lot of time to perform the operation, what is the way to speed up this? It takes 20 to 25s to load this query. ...
1
vote
0answers
14 views

pagination with 'no_found_rows' => true,

I have 100000 records in my database and so many meta query performed on it so it takes lot of time to perform the operation, have checked few articles and using them it suggest disable no_rows_found ...
0
votes
0answers
15 views

wp_pagenavi not working

Using the following code, the blog posts are output, but the page navigation is not. Also, the WP admin bar has no content, it is only a 32px high horizontal bar, and the site footer is not outputting....
0
votes
0answers
8 views

Need help with a query string (not normal query) to order posts by one custom field and filter by another

I'm working on a query string (a normal query can't be used in this particular situation) where I need to conditionally display a list of posts, and I'm having trouble saying "order by custom ...
0
votes
1answer
14 views

sanitize_post() is not sanitizing Post Object

I wanted to sanitize a WP_Query post object without using foreach. I used this method: $args = array( // ... ) $data = array(); $the_query = new WP_Query($args); $data["post"] = $the_query-...
0
votes
0answers
19 views

WooCommerce get all products with SKU [closed]

I want to get a list of products with sku and post id with this code, everything seems fine and ok with this code : $statuses = array('publish', 'draft'); // Args on the main query for ...
0
votes
1answer
32 views

Form checkbox value going to dynamic URL

Well, I have a Database made mostly with 'Advanced Custom Fields' in a page on my site that is supposed to get all the STORES (custom post type) of a city and show them to me, and by changing ...
0
votes
1answer
7 views

How to get specific multiple pages excerpts at homepage?

I'm trying to get the specific multiple pages excerpts at home page but it is showing all pages, it should show only the requested page IDs, need help please, below is the code I'm using. <?php ...
1
vote
1answer
19 views

How to avoid wp_query returning the same post I'm on in results?

I have an issue with WP_Query returning the same post I'm on in my results. At the bottom of my post page, I have this code: //Displays 3 Recent Posts: <section id="related-posts"> ...
0
votes
0answers
19 views

get_post_format is not returning standard

I am using Video post format and Standard post format. add_theme_support('post-formats', array('video')); While displaying all the blog posts, I want to show different icons for video post format and ...
1
vote
0answers
16 views

How to get all product attributes for filters in WooCommerce?

I am trying to figure out how WooCommerce decides which product attribute filters to bring. Because it does not only bring filterable attributes of the products in first page of an archive, but also ...
0
votes
0answers
66 views

Duplice post with standard WP loop - fixed by using query_posts() instead

I have an index.php file on a website designated as the blog page. I have an archive.php file which handles all the subsequent category pages. I ran into an issue on the archive page, where for one of ...
0
votes
0answers
43 views

Count author posts in certain category

I am using this code to only get authors who have posted in the 'Travel' category but the part 'category_name' => 'travel' doesn't seem to work. The code currently gets all posts in all categories. ...
0
votes
1answer
99 views

Make meta query treat meta_value as 1 or 0

My products have no in-stock status, just a quantity in stock. Is there any way to make meta query to treat its value as 0 or 1? Like, first the values that are not 0, then that are 0. My query as it ...
1
vote
0answers
11 views

Cluster WooCommerce products in each Category Archive by Tags assigned to products

Hello WordPress specialists. I am building my dream shop and I prepared a structure which I can not build now. Can you help me think about it? I prepared a product_cat categories which are based on ...
0
votes
1answer
21 views

Cannot get custom post

I want get all the post type st_tours associated to the taxonomy st_tour_type, when I browse the tour categories in the dashboard I have this link: taxonomy=st_tour_type&post_type=st_tours so I ...
0
votes
0answers
37 views

Loop categories with query

Is it possible to create a query for get the categories and sub categories? I want a more advanced query for this and get_terms or get_categories is not enough for me.
0
votes
1answer
26 views

find custom post type post by searching its custom field with my string

I have a custom post type called series and each post has a custom field named originaltitle. So in my code before I create a new post, I need to check if there is already a "series" with ...
2
votes
1answer
40 views

Meta query field order together with post_date order causes posts without the meta field to be unordered

I've managed to get wordpress to do a descending order on a meta_query field called start_date which is saved in Ymd format in the database by the ACF plugin. However in my query the other post types ...
0
votes
0answers
13 views

How to use the Term Object from a custom select field in a query

I have a WordPress site in which I want to show 2 recent posts from a specific category. I want to use custom fields (via ACF in this case) to allow the site admin to choose/change the category ...
1
vote
1answer
26 views

Meta Query relation “AND” not working

I want show (featured product) that instock, but this query just show in stock products. $query = array( 'post_type' => 'product', 'post_status' => 'publish', '...
0
votes
0answers
17 views

WordPress meta query for serialize associated array meta value

Serialize array value is: a:13:{s:7:"relaxed";a:7:{s:4:"name";s:7:"Relaxed";s:5:"votes";i:377;s:7:"term_id";s:5:"28595";s:4:"slug";...
1
vote
1answer
21 views

Fetch Record based on meta key dates

I want to write a query which fetches the data based on my meta key added. Meta key name is 'repeater'. This is my POST META. Serialized: a:3:{i:0;a:3:{s:9:"postdates";s:10:"2021-02-02&...
0
votes
1answer
26 views

Ajax filter with loadmore button

I'm struggling with ajax filters mixed with a load more button. I will try to be as clear as possible I've got a custom post type called Companies. I've created a page listing all of them , they can ...
0
votes
0answers
26 views

Query when is one or several values

I'm trying to make filter by querying different elements from a custom post type (stores) The problem is when I want to query the "styles", given that all stores have 2 or more instead of ...
2
votes
1answer
109 views

How to get data from Wordpress $wpdb into React Gutenberg Blocks Frontend?

I am using $wpdb to do a mysql query and get the data from a php file. $results = $wpdb->get_results("SELECT * FROM table_name"); Now, I have registered a Gutenberg block with the ...
1
vote
0answers
17 views

How can I display list of all posts from a specific author, with publish dates in the future, on an author archive page (author.php)?

I’m doing a site where all the posts are set to have a future date, and are published via a WP_Query. I know that this is somewhat going against the whole idea of how future-scheduled posts work, but ...
0
votes
0answers
7 views

Need to print category and subcategory of current post item (Custom post type)

I have a custom post type called products and that have category and subcategory (locations) like Delhi, India Karnataka, India Sharjah, UAE Above are the categories and subcategories(child). Here ...
0
votes
0answers
25 views

ElasticPress is (aparently) messing with my search filters

I recently installed ElasticPress on my woocommerce store, and it's working fine -- the product page is showing normally, and the search bar is working fine with the new elastic capabilities. However, ...
1
vote
2answers
26 views

If two first numbers exist in wp_meta_query value

I want to display a Custom post Type "Companies" filtered by zipcode. In my CPT I have an ACF field called 'companies_zip_code', their values looks like this : 29200 29860 35000 22350 ... I ...
1
vote
0answers
11 views

Custom posts visible in admin, but truncate in public

I am trying to return some custom post types. When I view the page as the logged in admin, all the posts are displayed unpaginated as expected/desired. But when I view the page as a logged out user, ...
0
votes
1answer
28 views

Random users always showing same 8 users

I am trying to display some random users on the page. It is changing the order of the users it is showing, but it is only showing the same users instead of randomizing from all users in the database. ...
-1
votes
1answer
40 views

get_posts shows current post, not defined posts with args

I want to show defined posts but get_posts shows current post without use definition in args.Why, how to solve it? what is difference between get_posts and wp query? thanks add_action( '...
1
vote
0answers
16 views

How do I correctly set up a WP-Query to only show upcoming event-posts?

The goal is to display event-posts only for upcoming events. Setup is Elementor Pro combined with Astra Pro theme. I added a custom date field called 'eventdatum' (d/m/Y) to posts and via the ...
0
votes
0answers
9 views

Using pre_get_posts filter to reset main query

How can I use pre_get_posts filter to reset main query? I want to use the filter in a page and reset the page query data and make a new query to display the latest posts.
1
vote
0answers
7 views

Why do WP_Query results change after updating unrelated Advanced Custom Fields (ACF)?

TLDR - After manually updating a custom post, my WP_Query will change it's sorting order and move that updated post to the end of the array response. I have a custom post type called Events that use ...
0
votes
0answers
6 views

Method for calculating the offset in order to use array_splice on wpQuery->posts

function getOffset($index, $length, $offset) { $result = 0; $transfer = 0; if ($index + 1 > $length) { return -1; } if ($index + 1 + $offset > $length) { $transfer = $index + 1 ...
1
vote
0answers
10 views

How to use load more custom post type data normal or according to on click category tab In WP

I have been developed a website and i has been create a page for portfolio page and I want to use load more data. I want the data to show up when the page is loaded and in the last show load more ...
0
votes
1answer
32 views

Selecting posts with a given meta value for a meta key

I'm trying to run a query that returns all the posts with a given value for a specific meta key. I know for a fact that this is none of the posts on my test server but it reports finding all the posts ...
0
votes
0answers
13 views

wp_query Pagination is not displaying

I have a basic wp_query that I am trying to apply pagination to like this... $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $args = array( 'post_type' => '...
0
votes
0answers
20 views

Search Query Name and meta fields

I try to search in custom post type by name or meta fields. I sucessfull search by name or by meta, but i can't mix the search. add_filter( 'pre_get_posts', 'meta_search_query'); function ...
0
votes
0answers
16 views

Set custom ordering to WordPress / Elementor Pro post query

I made a task system using Elementor Pro posts, I want custom ordering but I have problem. Ordering should be "High" first > oldest first, then after that "Normal" > oldest ...
0
votes
0answers
16 views

any word search Wordpress

By default, WordPress searches by keyword. What this means is that when passed the search query football boots, WordPress builds the following for the WHERE clause: ((wp_posts.post_title LIKE '%...
0
votes
0answers
25 views

query_vars treat as single var from URL

I want to use the link parameter from URL as one query_var. If I visit the page where [flipwoo] is in, for example: https://test.com/test/?link=https://test.com/?download_file=1953&order=...
0
votes
0answers
27 views

How to create author.php with the help of wordpress pages feature

I need to create author posts archive with the help of Wordpress pages feature. That's why I created a page with the slug "author". Now when I want to enter author page , it forward me to ...
2
votes
0answers
29 views

How to search by a post and a category name on wordpress at the same time?

I wanna change the default behavior of wordpress search engine. Basically, I want to choose between 2 paths when the user informs a term on the search input: Find the posts or custom posts that have ...
0
votes
0answers
9 views

Arranging products in Custom Taxonomy Archive by Category with new WP_Query

I'm using a shortcode and thus using a new Wp_Query - but If I could do it with pre_get_posts in a shortcode I'd also be happy. On a custom taxonomy page "range" I need to group products by ...
0
votes
0answers
8 views

page can't redirect in Faq custom plugin in admin page

I was trying to delete row in admin page for Faq custom plugin which I made. I made custom Faq plugin and connected it through database. Get all data on front-end and in admin page of plugin. I wanted ...
0
votes
0answers
17 views

get_posts function not returning any results

I'm currently working with WP and also using WPML. I'm trying to retrieve posts using the function get_posts but the function is not working. This is what I'm trying so far. $posts = get_posts(array( ...
1
vote
2answers
200 views

Combining sorted and random CPT

I have two Custom Post Types and would like to display one of them sorted (by title) and the other one at random places in the same query. So CPT A (sorted) en CPT B (random): A1 A2 A3 B2 A4 A5 B5 A6 ...

1
2 3 4 5
106