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,754 questions
0
votes
0
answers
18
views
Integrate external data as "virtual" custom posts to process them via WP loop
I'm struggling on a scenario that feels quite simple in theory but might already be hard for me to describe accurately (in English):
Basically, there's an external (SQL) data source, let's call it &...
0
votes
2
answers
46
views
Deleting old WordPress pages [closed]
I have a website on WordPress, we recently rebranded the website with Avada website builder, but I can't figure out how to get rid of the old links. They have nothing on them, it just says page not ...
0
votes
0
answers
46
views
Exclude specific DIV ID from WordPress search results without plugin
For example, in a WordPress content has the following text and Div element.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type ...
1
vote
1
answer
74
views
How do I use fields => ids in an array with WP Query?
In my example below, when using fields => ids https://developer.wordpress.org/reference/classes/wp_query/#return-fields-parameter to get an array of post IDs, why does var_dump($args->posts) ...
1
vote
1
answer
45
views
Using meta_query with non-meta_query criteria in a WP_Query using OR instead of AND
I have a custom post type that contains some imported data in a meta field named keywords. For various reasons, there is a requirement where if a user searches ($s) they should get results that match ...
1
vote
1
answer
59
views
Wordpress Query with meta_key and order by another meta_key
I want to output data from a PostType.
This query works:
$loop = new WP_Query( array(
'post_type' => 'studio',
'post_status' => 'publish',
'posts_per_page' => -1 ,
'...
0
votes
2
answers
95
views
WP_Query returns wrong post when searching by title?
The comments left in my code explain what's going on.
protected function fetchLocationByTitle($title) {
/*
* The WP Query class returns wrong post when searching by title using the
* ...
0
votes
2
answers
114
views
Output parent/child categories and posts in that parent/child hierarchy
I'm using the WP_Query loop to output all categories and their posts into a jQuery accordion, using the category name as the accordion header, with posts from each category inside each accordion.
The ...
2
votes
3
answers
249
views
How to change WP Query to display related posts
I am creating a WP block theme and want to show related posts on the single post page. Using the Query Loop block, I have added a new pattern that displays the latest posts. Now I want to change the ...
0
votes
0
answers
43
views
How to adjust meta value to UTC time in WP Query
I'm displaying three lists of events on my site: past events, current events, and future events. The lists are sorted by a custom date time field. The code I have is currently working, but Wordpress ...
0
votes
1
answer
54
views
WP Query to display events and posts at the same page
I am trying to sort events (from event-organiser plugin) and posts in a page where posts would be ordered by date and events ordered by eventstart date with a WP_Query by selecting the appropriate ...
0
votes
1
answer
113
views
Construct WP_Query args for multiple taxonomies and sort by terms
I'm trying to create a list of related posts from a couple of custom taxonomies and then sort them starting with one taxonomy's terms.
The post type is "work" and the two taxonomies are &...
0
votes
1
answer
53
views
get posts returns results but wp_query does not
I am using a custom template for a members page which looks something like this
<?php
/**
* Template Name: Our Members
*
* @package Demo
*/
$args = [
"post_type" => "...
0
votes
0
answers
70
views
Need help with Query Loop. Need to get current taxonomy term and its posts and group them by a different selected taxonomy term
Example:
Treatment - (Term of resource_type Taxonomy)
Resource Name 1 (term of resource_name Taxonomy)
Resource 1 - Post 1
Resource 1 - Post 2
Resource Name 2 (term of resource_name Taxonomy)
...
0
votes
0
answers
70
views
Order by multiple custom fields within woocommerce hook for catalog ordering (woocommerce_get_catalog_ordering_args)
I'm still learning and have looked at many articles on this site (like this one) and others (my favorite: here), including WP documentation and woocommerce documentation. I'm trying to (a) use a ...