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.
5,753
questions
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 &...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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',
...
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 = $...
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, '...
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 ...
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 ...
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 ...
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',
...
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 ...