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

15 30 50 per page
1
2 3 4 5
192