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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
23 views

Filtering with Attributes - how to display all non-queried products below query

I addded attributes to filter out products, based on their selection. For instance, I have field named 'tiled' as yes or no. If person ticks 'yes', all the products with the attribute of 'yes' are ...
JohnLyons's user avatar
1 vote
0 answers
21 views

Order by Post Title in WP Query not working

Its wired, i've try to order a custom post type simply by title, and still struggle. Of cause i checkt the dWP dev resources and much more. See always the same solutions, but its not working. Maybe I ...
PXD's user avatar
  • 11
1 vote
0 answers
40 views

Display posts in correct month order using single date custom field

I have developed a WP Query that displays posts from a custom post type and taxonomy, and orders them by date using a custom field. The posts have a single Advanced Custom Fields date picker field ...
Mike Hermary's user avatar
0 votes
1 answer
22 views

How do I group results from wp-query

I've got a custom post type for staff. The fields are first_name, last_name, job_title, telephone, email, and notes. All staff are categorized by location using WP core Category. I need to output the ...
banacan's user avatar
0 votes
0 answers
36 views

Using a Query Loop Block with Variables (Custom Meta)

Query Loop Block is extraordinarily powerful. I am using FSE. I want to filter data via any number of meta keys and values from the editor. I think it might be good if the editor could allow a method ...
Tommie C.'s user avatar
  • 101
0 votes
1 answer
15 views

How could I prevent using the same custom loop in a template file when I only need to change one meta_query parameter?

I am displaying a set of upcoming fixtures for two cricket teams on the same page. The fixtures are created from a CPT and the relevant team is selected from a custom field. I have everything working ...
Craig Watson's user avatar
0 votes
1 answer
16 views

wp_insert_term how to insert "<" or ">" in description

so i'm trying to insert an image to wp_insert_term() by $args = array ( 'description' => '<img src="src">'); wp_insert_term( 'sample', 'taxonomy', $args ) ; However it is being ...
Kenneth Gervacio's user avatar
0 votes
0 answers
26 views

How to delete widget in Wordpress?

I would like to remove the widget that is in the attached screenshot. Recently I managed to write a short code in the additional CSS code in Wordpress. Unfortunately, I changed the theme and this code ...
Nr X's user avatar
  • 1
0 votes
1 answer
22 views

has_term not returning anything

I have a queried list of calendar events that I am trying to check if they have custom taxonomy terms. Within the loop, I have a list of "if" statements for outputting terms from the ...
GrabBag-Charles's user avatar
0 votes
1 answer
21 views

How could i add username field in WooCommerce

I don't know how to add username field in registration page. There is no settings about this also. Used to be there is a setting about adding a username field but not now how could i add username ...
obalota's user avatar
2 votes
1 answer
115 views

$wpdb->get_results() into foreach() returns always the word "Array" on top of the list . How to get rid of?

I'm extracting field content forma a simple table under WordPress. The table contains the fields as in the screenshot here below and I need to extract all the values in rul_value for the row in which ...
Tormy Van Cool's user avatar
0 votes
1 answer
13 views

Add up all numbers from a WordPress query [closed]

I have the following code $query = new WP_Query($args); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $post_id = ...
iWebbers's user avatar
0 votes
0 answers
61 views

order meta_value_num not working

I have this code: <?php $most_popular_args = array( 'post_type' => 'post', 'posts_per_page' => 10, 'orderby' => 'meta_value_num', '...
Lucas Wojnar's user avatar
0 votes
0 answers
29 views

Help me understand this WP_Query argument

I am trying to understand what arguments are used to order products on a page by using var_dump on $wp_query->query_vars. I get this arguement that I don't understand how it's working [orderby] =&...
Atif's user avatar
  • 115
0 votes
0 answers
25 views

Problem making a WPQuery with ACF boolean

Well after hours and hours I find myself finally here, I am building a gutenberg block that is getting a custom post type data and making little cards with it, it works very well if I want to get: All ...
Cheoncio's user avatar
0 votes
0 answers
15 views

How to add an extra parameter to searches on the admin listing screen for my custom post type

I have defined a custom post type. On the admin listing screen I am filtering this based on a querystring argument. So if my querystring includes 'filter=abc' I show a subset of my custom posts, if ...
zcesl53's user avatar
  • 35
0 votes
0 answers
18 views

wp_query returns all posts even with post__in and posts_per_page

I have this code which shouldn't return all the post in DB. It should return only 3 posts. $sql = "SELECT wp_posts.ID FROM wp_posts WHERE 1=1 AND ((wp_posts.post_type = 'post' ...
João Carlos Zimmermann's user avatar
0 votes
0 answers
20 views

Pre defined checkbox / radio button state based on value stored in ACF fields in checkout form WooCommerce

I have created custom fields using acf and created a form to get inputs stored in this fields as user meta, now i used those fields value and displayed on checkout form as custom checkout fields all ...
yasar 21's user avatar
2 votes
1 answer
52 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
  • 173
0 votes
1 answer
33 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
28 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
15 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
44 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
64 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
25 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
66 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
24 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
49 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
47 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
24 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
36 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
98 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
26 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
109 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
112 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
32 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
32 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
28 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
32 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
20 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
92 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
15 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
52 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
22 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
27 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
31 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
  • 43
0 votes
0 answers
29 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
22 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
67 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
28 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

1
2 3 4 5
115