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.

1 vote
1 answer
39 views

How to create a three column blog layout with a single query and with three different classes?

I am trying to achieve the following layout : I have created a shortcode for this but I am not getting the desired result. Can anyone guide me where I am getting it wrong. Here is full shortcode. ...
kalyan's user avatar
  • 163
0 votes
1 answer
19 views

Adding a language rule and displaying posts with a custom taxonomy term on its archive page

The WordPress website I'm working on is available in two languages using Polylang, en-US and en-PH. I use CPT UI and have a custom taxonomy "subtopic" that is not multilingual. Under "...
Sum's user avatar
  • 11
0 votes
0 answers
20 views

meta_query post_date not returning results

I'm working on a query where I have a few conditions, one of them involving post_date. However, whenever I try to write my query, post_date doesn't return any matches. If I comment that part out, it ...
Nicole's user avatar
  • 1
0 votes
0 answers
11 views

Use custom url params with value from a custom field to return the post containing the field value

I got a list of links from an external api, that I want to associate with wordpress posts. The api links are distinguishable by an id. In each Wordpress post, there is a custom field where this id is ...
oivind's user avatar
  • 101
0 votes
0 answers
42 views

"Page not found" while on page 2 from pagination menu

all. I'm getting a "Page not found" message in my firefox tab when I click page 2 in my pagination menu. What's odd is, the content shows up just fine on all paginated pages. I've tried ...
harshclimate's user avatar
0 votes
1 answer
37 views

What is the easiest way to create a custom field archive?

So, here is the issue: I am using a plugin named User Submitted Posts, and it works great on its part. However, I still want to have that user content page the Twenty Twenty Four theme has by default, ...
Grond's user avatar
  • 1
0 votes
1 answer
22 views

WP Query: orderby with one meta key, but multiple values

I'm trying to order a wp_query using one custom field. It is a radio group with three values: G, S and B (These represent Gold, Silver and Basic). I've been following the documentation and have looked ...
Laurence O'Hare-Carroll's user avatar
0 votes
0 answers
20 views

Show post in elementor based on views and specific category with query id feature in elementor

I have two functions for query filter: function my_query_filter_most_views( $query ) { $query->set( 'orderby', 'meta_value_num' ); $query->set( 'meta_key', 'entry_views' ); $...
Danial Sohail's user avatar
0 votes
1 answer
21 views

Not displaying the wp_query object for the following code in the frontend

add_action('template_redirect', function () { global $wp_query; echo '<pre>'; print_r($wp_query); echo '</pre>'; die; });
Soumyadeep Chandra's user avatar
0 votes
0 answers
20 views

Filtering custom post type list in admin by custom meta key/value

I am trying to add an additional filter to be able to filter by a custom meta value but it is not returning any values when I would expect it to. Here is my code to add the filter dropdown (this seems ...
Tommizzy's user avatar
0 votes
0 answers
37 views

Why WP_Query with the same arguments retrieves different results?

wp_reset_query(); wp_reset_postdata(); $post = null; $course_args = array( 'post_status' => 'publish', 'post_type' => 'course', 'posts_per_page' => 5, 'order' => '...
0 votes
0 answers
15 views

WP_Query on custom taxonomy -> Location and Activity

A store location site displays stores based on region, town OR activity. I am using the WP Store Locator plugin and also using Divi Builder to create the pages. This is proving quite powerful and I ...
Adam Fletcher's user avatar
0 votes
1 answer
28 views

Orderby meta _value that is saved as an array

I want to order a WP_User_Query by a meta value. The meta key is a multi-select field, and the value is saved as an array. When I do a print_r of get_user_meta($user_id,'committee',true) this is what ...
LBF's user avatar
  • 529
0 votes
2 answers
49 views

How to use meta_query to retrieve posts from multiple custom post type

I am having two custom post type "meet_our_community" and "news" I have added a checkbox field named 'add_to_meet_our_community' from the acf to 'news' post type. Now I when tried ...
Amal's user avatar
  • 1
0 votes
1 answer
21 views

WP-Query and Searching Inside Arrays

I have a plugin that stories a grid of integers in meta fields like so: 'pricing_info' => array ( 0 => '1 | 1 | 1', 1 => '1.5 | 1.5 | 1.5', 2 => '22 | 22 | 22', ), So its ...
M. Jam's user avatar
  • 1
0 votes
1 answer
19 views

Modify WordPress Search

I'm facing a challenge with a WordPress project and I would appreciate the community's help in solving it. The issue lies with the search functionality. When customers type in a search term, such as &...
Roniery Rêgo's user avatar
2 votes
1 answer
86 views

Equivalent of url_to_postid() for non-post URLs?

If I do url_to_postid("https://example.com/2024/05/test") I get back an int which I can then pass to get_post(). That works perfectly. But what if I request a tag or a year? What's the ...
Terence Eden's user avatar
0 votes
0 answers
26 views

Block Editor - Wordpress 6.1 - CPT Archive Issue - While the title changes in the loop, all records display the same data

I am using the block editor with CPT. I have a loop that iterates though my CPT. The title changes for each record but not the data in the CPT. I am using a shortcode to display my custom post type ...
spreaderman's user avatar
0 votes
1 answer
26 views

WP_Query not using relation key as expected and not producing any results

I have created a custom post type service-provider with custom taxonomies region and service-category - By itself, this search works as expected BUT I want to also search on an ACF field. I have an ...
php-b-grader's user avatar
0 votes
1 answer
26 views

SQL command to delete bulk WP post specific

I have an author named News Agencies and it has 50000 WordPress post from 5 months, I need to delete news agencies post from this specific author of 3 months only. Is there any SQLI command to do this ...
C I Wing's user avatar
1 vote
1 answer
25 views

Showing all posts of the current custom taxonomy on archive page

I have created a custom post (houses) and a custom taxonomy (houses_area). On each houses_area archive page, I want to see all the posts displayed by alphabetical order. I get stuck in calling the ...
Anna's user avatar
  • 21
1 vote
0 answers
18 views

functions with get_post_meta

I'm working on a function for bibliographic citations with get_post_meta. A bibliographic citation contains several elements, (author, date, title, etc.), each of these elements is a get_post_meta ...
Oox's user avatar
  • 53
0 votes
0 answers
35 views

$wp_query->found_posts; returns zero

I'm merging 2 queries using the code below and it works as I expected except for the $main_query->found_posts; returning 0. $args = array( 'post_type' => 'carellcars', ...
Jobbie Daddy's user avatar
0 votes
0 answers
11 views

How to prevent random 302 canonical-ish redirect on custom template

I'm trying to create a subpost location - like /embed or /feed - for photo galleries. // this defines the location logic if (!function_exists('is_gallery')) { function is_gallery() { $uri = $...
lucian's user avatar
  • 322
0 votes
1 answer
31 views

Exclude page ID AND current page from wp_query of a Parent page

I would like to display a list of all children pages of parent page ID #2. I exclude one of child page which is ID #4 : <?php $args = array( 'post_type' => 'page', 'posts_per_page' => -1, '...
Hellooo's user avatar
0 votes
0 answers
19 views

Instead of returning post content, return code that I specify

I created custom post types called funds. My page has over 200 of them. After buiding the page the back end payment processor changed the way they want to display the form for donating. It is now a ...
Christa's user avatar
0 votes
1 answer
25 views

Custom WP Query with neither ASC or DESC

I have found several posts like my question but never really found a good answer. I have ACF fields on Posts. One of them is a radio, with 3 values (For Sale, Pending and Sold). I have used a Query to ...
david simon's user avatar
0 votes
0 answers
24 views

Inherit args from the main wp_query or wp_comment_query to my custom query

I want to create a custom wp query but inheriting the args of the main query both for wp_query and the wp_comment_query. WP QUERY: $args = array( // custom args ) // Here I need some method to join ...
Stefano's user avatar
  • 33
0 votes
0 answers
26 views

WP_Query does not return the result even if the data is present in the database

I have a plugin that has following code $posts = new WP_Query([ 'post_type' => 'campaign', 'meta_query' => [ 'relation' => 'AND', ...
Praneetha's user avatar
  • 103
0 votes
1 answer
21 views

Quering a post object based on another related post object

I have two post types - Ticket and Event Each ticket has a meta called 'event_id' which connects it to an Event. Suppose I want to fetch all events with more than 3 tickets. I want to do it in a ...
mrkarma4ya's user avatar
0 votes
0 answers
36 views

get last part of page url and add it as cat in wp_query

I have a page URL : https://mwallpaper.ir/mobile-wallpapers/birds and I grabbed last part of URL with this filter : add_filter( 'example_filter', 'catslug_callback' ); function catslug_callback( $...
ehsan's user avatar
  • 13
2 votes
0 answers
18 views

get_meta_sql hook is not firing

WP_Query uses WP_Meta_Query. I thought this calls the WP_Meta_Query::get_sql() to define the meta query SQL which is where the get_meta_sql filter is applied. I can't get the get_meta_sql filter to ...
Adam's user avatar
  • 103
0 votes
1 answer
23 views

Filter on one post type with taxonimy and get other post type

I would like to fetch my posts of type 'news', 'videos', 'webinars', 'whitepapers', 'testimonials', and 'landing-pages' and apply a "filter" to only get the landing-pages type with the ...
WypSteur's user avatar
0 votes
1 answer
67 views

Passing a variable containing a comma separated list of values in a meta-query

My objective here is to collect a series of values from a custom repeater field into a comma separated list so they can be used in a meta query. The first part of this is operational, and I think ...
mtm's user avatar
  • 43
2 votes
1 answer
23 views

WP_query() Simulate Missing "NOT" relation to Reverse Results?

I have a working and complex "args" ("tax_query") array which returns results. I now wish to get the missing results, this is a "boolean" NOT operation (which "...
Dennis Bareis's user avatar
0 votes
1 answer
84 views

WP_Query for multiple post types just shows one

I have an issue, that I do not really understand. I hope, you can help me. I would like to have a WP_query for multiple post types: $query = array( 'category_name' => $category, 'post_type' =&...
wepli23's user avatar
0 votes
0 answers
22 views

How to display only posts from the last day with posts published?

The goal is to show today's published posts or, if there's none, the last day's with posts published posts. I found this old question, but the code suggested uses query_posts. I'd like to use WP_Query....
Rodrigo G.'s user avatar
1 vote
0 answers
54 views

WP_query with ajax filter not working with input fields

I'm having trouble with my query when using ajax to filter the posts. I have a page where the posts of post type 'activiteiten' are loaded when the start_date custom field has today's date or a date ...
Thessa Verbruggen's user avatar
1 vote
1 answer
47 views

External WP_Query call from PHP crashed after version update

I have an external script that does some DB maintenance through WP_Query and similar functions. It used to work great, but now after a PHP version update (from 7 to 8) it stopped working. The ...
Binyomin's user avatar
  • 113
0 votes
0 answers
34 views

Show the author only own types of publications. (JetEngine, Elementor)

I created a custom post called Locations using Elementor + JetEngine. I also created a User Profile Builder Dashboard with the help of this, where the user (client) can add a location. But the problem ...
user239691's user avatar
1 vote
0 answers
29 views

Include posts with a specific custom taxonomy term in author page

I created a "co_writer" custom taxonomy with author names as terms. I only use this taxonomy to output their names as co-authors on multi-author posts. As such, posts in which an author's ...
Sum's user avatar
  • 11
1 vote
0 answers
26 views

WP_Query - Variable input

Update I think I've completed this, but please clean up if there is a better way. Code is the new working version Original Issue This page template query works & displays the custom posts items ...
Lucas's user avatar
  • 11
0 votes
1 answer
175 views

pretty url for query parametr

I want this link: site.com/c/web/theme/?filter_cms=wp Convert to: site.com/c/web/theme/wp/ I found this code and edited it a bit: add_action('init', function () { add_rewrite_rule('^c/web/theme/([...
Monoor's user avatar
  • 13
1 vote
1 answer
142 views

query loop "inherit query from template" prevents setting sort order

I need all auto-generated category pages to sort oldest-to-newest I'm editing my "All Archives" template in block editor but I'm not having any success it contains a query loop with "...
Displayname71's user avatar
0 votes
0 answers
186 views

Rewrite URL custom search query

I have this url: mydomain.com/?s="SEARCH TERM"&categoria="WORDPRESS CATEGORY OF POSTS"&province="CUSTOM POST FIELD"&poblacion="CUSTOM POST FIELD" ...
Maseres's user avatar
1 vote
1 answer
119 views

WP_Query to find any published post with ID greater than given ID

With WP_Query, I want to retrieve all the published posts with ID greater than a particular ID. Is this possible? I could not find any way. I tried many variations of this, but I don't get the ...
Life after Guest's user avatar
0 votes
1 answer
29 views

Splitting query results, on the frontend, into separate sections based on meta value without multiple loops?

I have a query, sorted by a meta field, and I am trying to figure out how to split the query into different sections based on the meta field. Essentially I want there to be an h2 and a ul for each ...
user13286's user avatar
  • 255
1 vote
1 answer
108 views

Query multiple post types - Order by type and post title title

I have three custom post types which I need to retrieve posts for within one wp_query. I am seeking to return the posts in the order of post type, as well as by post title. Within the question ...
Allen Tullett's user avatar
0 votes
1 answer
24 views

Extra filtering on post query

I have a membership system and want to restrict some posts depending on what level of membership they have. We have some voucher codes which bronze members are elegible for, some voucher codes for ...
StripyTiger's user avatar
0 votes
1 answer
49 views

Query Multiple Post Types and Paginate Newly Created List

I know this has be asked several times but i cant seem to find the answer anywhere. My site has a resources page which is my archive for all resources (archive-resources.php). I'm trying to also ...
user2402492's user avatar

15 30 50 per page
1
2 3 4 5
116