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
1
vote
2
answers
2k
views
How Can I use WP_Query to Only Display 1 Post from Custom Post Type if Query Returns Posts with Matching ID in Custom Field
I have searched high and low for a solution and couldn't find anything; hopefully someone here more skilled than myself can lend a hand.
I have two testimonial videos (from a video custom post type) ...
1
vote
1
answer
1k
views
WP_Query: "post_parent" and "post_type" combination returning strange results
I'm experiencing some interesting results using post_parent along with post_type (local, WP 5.8):
I have a custom post type project (with 'hierarchical' => true) where I'm grabbing all child posts ...
0
votes
2
answers
1k
views
Merge two queries and remove duplicate
I want to merge two queries together and remove duplicate.
I got it working individually. Now I got it working together but the results are not mixed and the duplicates are not removed. So I got the ...
1
vote
1
answer
4k
views
How to filter my search in post if contains a word in title, content or excerpt?
I'm trying to filter one search, and I'm interested in know if a word is inside the title, the content or the excerpt but without luck and finally I'm stucked.
$args = array(
'post_type' =...
0
votes
1
answer
2k
views
Pagination not working in custom loop WP_Query
Please help with pagination
I have code that works fine (functions.php)
function projects_custom_number_of_posts( $query ) {
$query->set( 'posts_per_page', 2 );
return;
}
add_action( '...
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. ...
0
votes
1
answer
833
views
Why pagination is not working with tax_query param?
this is my query:
$p_query = new WP_Query(array(
'post_type' => $post_type
,'post_status' => 'publish'
,'posts_per_page' => $per_page // 6
,'paged' => $page // 2
,'...
1
vote
1
answer
5k
views
Dynamic content based on a URL parameter
So, I'm doing some wordpress development studies and classes, and now I got an project to work on, and need to get the following task done: I'm doing a telecom website. The site has a page called "Buy"...
0
votes
1
answer
693
views
Display related CPT with custom taxonomy
I have two custom post types: "storefront_location" and "services"
These are linked by a custom taxonomy "location"
I am building a post template for "...
1
vote
1
answer
2k
views
WP_Query tax query part of slug
I have problem with filtering post with tax query.
I have a custom taxonomy called 'actors' and example of the slug is 'david-hasselhoff'. The problem is the post is found when I search with 'david ...
5
votes
1
answer
1k
views
Order wp_query by calculated field
Hi I'm working on a store locator.
I have a custom post "clinics" where I save clinic details (address,.., lat, lng). Each time I publish a new clinic I save post_id, lat and lng also in a custom ...
0
votes
1
answer
785
views
Custom taxonomy and query multi conditions
I have this query
$query->set( 'tax_query', array(
'relation' => 'OR',
array(
'taxonomy' => 'location',
...
0
votes
1
answer
690
views
Unusual high query of user meta data
We have a WordPress installation with many plugins installed. The site is not that highly frequented (maybe 10-20 concurrent users). I know the amount of plugins comes at a cost of performance. ...
0
votes
2
answers
932
views
Unable to get all tags from specific categories
Page in question.
I'm trying to use a WP_Query(); targeting specific categories and displaying all the tags used for posts within those categories.
I noticed that some tags, like truffles aren't ...
1
vote
2
answers
1k
views
the_post() within switch_to_blog() altering my excerpt
I have a strange problem I'm facing when using WP_Query with multisite in a plugin I'm writing which hooks into add_meta_boxes. I'm wanting to display all post titles in a dropdown in a meta box.
...