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
5 views

Multiple tags not getting displayed

I want to retrieve combined tag-results within my tag.php template. That tag-template-page can only be fired in that 1 specific use case, as I have no search boxes or forms available anywhere in my ...
0
votes
0answers
9 views

How to create loop of posts except post ID defined via ACF field

I am creating a custom news page with two columns - 1st column - featured post - using a ACF text field to add post ID to show, ie: 12345 - works fine. 2nd column - remaining news, showing all other ...
-1
votes
0answers
21 views

WP_Query - Bug with multiple post types

I'm creating a WP_Query, and I need it to get multiple post types, and it's working REALLY strangely. I have 3 post types: 'equipo','accion' & 'publicacion'. And my code looks sth like this: $args ...
0
votes
0answers
8 views

Build a custom search date filter based on date ranges in ACF text field

I have cars not available during range of periods. These periods are on one ACF text fields (in json) named date_not_available like this : [ {"from":"22/03/2021","to":&...
1
vote
0answers
15 views

Using featured image from another page

I have the following code which, if a page is a sub-page of 'Portfolio' (ID 12), will use the featured image of the Portfolio page rather than it's own. However, I also have a page of 'Services' with ...
0
votes
0answers
5 views

filter products with first letter of product tittle an all product archive pages

I want to filter woocommerce products with first letter of their titles by request of get method like: ?alph=A I try bellow code but had no success: in function.php add_filter( 'posts_where', '...
0
votes
0answers
7 views

How to add post author selection box in WordPress post type post?

In my WordPress post, I want to add a box for select post author. In the first website, I have included it but in the second website it is not included.
0
votes
0answers
16 views

Real time post display on home page (as soon as they are published)

I have noticed this becoming a trend with comments and now posts. I'm sure many sites (especially community ones) will implement this. Here's exactly what I mean, click here: https://stackexchange.com/...
0
votes
0answers
15 views

Display average rating in post archive

I have a multi author website where every registered user can submit posts and give star rating for his own custom posts. I am trying to display the average star rating in the current archive query. ...
0
votes
1answer
20 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
16 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
1answer
35 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
17 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
100 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
22 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
110 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
27 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
8 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 ...

1
2 3 4 5
106