"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 default object that holds the main query object on each WordPress page.

learn more… | top users | synonyms

1
vote
1answer
60 views

How to prevent writing duplicate loops?

So i have some pages where i want to show my custom post type 'events' only by the last 5 posts (secondary query: WP_Query object) and some pages where i want to show all posts (for instance archive ...
0
votes
0answers
29 views

wp_query - Modify $query to include duplicate content

I'm setting some featured content through the customizer (it's saved in theme_mod); Using the pre_get_posts hook, I'm retireving the feature pages in this way: ...
0
votes
1answer
33 views

Can't get the_content to show

I'm using the following code to get posts from a category in a page. This category uses ACF for some fields. However, when I try to output everything, it shows everything but the_content. For better ...
0
votes
3answers
27 views

Filter out a meta key in the Search results page with two CPT

I have two CPT: Listings and Events. In Events I have custom fields for the start and end dates. What I need is a way to filter out any events that are past the current date. What I have right now ...
3
votes
2answers
96 views

Return only Count from a wp_query request?

Is it possible with the standard build-in tools in Wordpress to get wp_query to only return the count of an query? Right now, I’ve a query which has several meta_queries but what the only thing I’m ...
0
votes
0answers
34 views

Both WP_Query and get_posts returning 1 post

I am having a weird issue. Both WP_Query and get_posts returning only one result, i.e only the latest post. Never faced this before.. The WP_Query: function custom_tsr_query() { $the_query = ...
0
votes
1answer
20 views

Query Set Order By Author

I am attempting to orderby the author_name when you click on the Author arrow on a list of tickets. When you click the arrow, the names are ordering by something I cannot identify. I want them to ...
0
votes
1answer
35 views

Loop with Custom Post Type and Taxonomies

Regards, i've a problem. What i want: Show a toggle with loop from Custom Post Type I create post type: Episodio And a Taxonomy: Temporada I create this loop: <?php $post_type = ...
0
votes
0answers
35 views

2 loops with pagination on a single loop

On a page I want to always show the most recent post on top with a different layout, and have the rest of the posts listed below. So I created a template page with these 2 loops. But I cannot figure ...
-1
votes
2answers
66 views

Cannot exclude particular post from loop of custom post type

I have a custom post type (from a theme installed by previous developer), and here is the code of loop which retrieve the post and display them. <?php // Counter $post_count = 1; // Query ...
0
votes
1answer
103 views

WooCommerce search products between price range using WP_Query

I am currently building my own custom advanced search functionality for a WordPress website with Woocommerce. You should be able to search using: Category Min/Max price My current progress is ...
1
vote
1answer
53 views

Any number in meta key (wp query)

I have such a query. The field modules_%_text is advanced custom fields flexible field where % should stand for ANY ROW number, it seams that it should work like that, however it's not. What i'm doing ...
0
votes
1answer
17 views

Custom search (wp query by custom fields)

I'm building custom search. Actually it's just need to check custom field value. The custom field is called 'summary'. However i'm not sure what i'm doing wrong as it is not working. Maybe someone ...
0
votes
2answers
41 views

Custom shortcode not displaying categories and correct date

I wrote a short code to work with an event plugin (the plugin creates the custom post type of event). I want to pull all future events from the database that use a specific category and list them on ...
0
votes
1answer
53 views

WP_Query custom order and pagination

I am seeing some strange behaviour when combining a custom order with pagination when using WP_Query. The arguments for my query are as follows: $args = array( 'post_type' => 'news', ...
0
votes
2answers
33 views

Make a WP Query search match exactly the search term

I'm using WP Query and the results coming back when using the search term aren't working as I wish. For example searching for 'art' returns also results for words containing 'art' such as 'part'. How ...
3
votes
3answers
110 views

Query posts distinct authors

I am trying to get post from a category ordered random, but making sure that the author does not repeat itself. So I have this query which works as intended, but there is the chance that the author ...
0
votes
1answer
45 views

WP_Query - using category__and when one of the categories is 0

I am passing a variable $category to category__and, and it works unless $category = 0; 'category__and' => array(4) // works 'category__and' => array($category, 4) // works if category > 1 ...
-1
votes
0answers
20 views

Get posts by tag OR with the given category

I have posts & custom post types. They can be either categorized in fashion or tagged with featured. So I want to pull the posts within that category or tagged with featured. This is what I have ...
0
votes
1answer
27 views

modifying meta_query on parse_query

In the parse_query filter hook I'm doing: if ( is_admin() && $pagenow == 'edit.php' && isset( $_GET['ysr_homepage_filter'] ) && $_GET['ysr_homepage_filter'] == '1' ) { ...
0
votes
1answer
14 views

List of child pages fetch next results at link click

I have a list of child pages which are getting displayed as links to those pages. Im displaying it in a certain div with a maximum of 6 results. What I want is I have a "a href" which is called ...
0
votes
0answers
12 views

Search results for author account pages

I'm looking to find out if there are any plugins / code out there for Wordpress search to return results for user author accounts. NOT posts from authors. NOT pages that authors have created, but the ...
0
votes
1answer
16 views

Display post from custom post type

I have this Custom Post Type (CPT) defined at functions.php: register_post_type( 'opinion', array( 'label' => __( 'Opiniones' ), 'singular_label' => __( ...
4
votes
1answer
57 views

WP_Query by post ID doesn't work if post is in custom post_status

I want to display a single post by its ID using WP_Query(). To do this, I use the following argument: $args = array( 'p' => 61202); That should work, but does not seem to work if the post is ...
0
votes
1answer
66 views

Pagination for custom query throws 404 errors on last pages [duplicate]

I'm using a custom query to get all CPT posts for the author in author.php. I have a lot of authors and a lot of content so I'm using the wp pagenavi plugin to paginate between these posts. For some ...
0
votes
1answer
14 views

Display images with same specific value?

I'm trying to make a slider for my website, but I'm a little bit stuck right now. The thing is that I don't want to use any plugin (I prefer to try to learn how to do this, and also most plugins have ...
0
votes
1answer
40 views

More efficient way to list posts by category [duplicate]

I have a page that lists posts grouped by category. Here is the current code: <?php $cats = get_terms('category'); foreach ($cats as $cat) { $cat_id= $cat->term_id; echo ...
0
votes
1answer
29 views

Order posts by custom column using pre_get_posts

Is it possible to sort posts by custom column in wp_posts table (in this case, 'fav_count' column) using pre_get_posts filter? If not, is there any other way to do this before the main query is run, ...
0
votes
0answers
26 views

How to stop wp_query searching pages as well as the specified CPT

I have a CPT that has multiple fields. I have a custom input form that takes a name as the input and this is stored in the $surname variable. I need to search my CPT for that name either as the CPT ...
0
votes
0answers
21 views

Sorting “menu_order” does not work in WP Query with multiple post types

When i use my WP Query as follows: $post_types = array('research'); $args = array( 'posts_per_page' => 10, 'orderby' => 'menu_order', 'order' => 'asc', ...
0
votes
1answer
22 views

If orderby parameter using pre_get_posts is the same for multiple posts what fallback does the query use?

So I have 3 custom post types that I want to order by menu_order & have 'date' as the fallback parameter as the majority of posts will have the default menu order of '0'. It would be nice if ...
2
votes
1answer
33 views

How to do a query on custom taxonomies that is uncategorised?

I have a custom taxonomy and I wish to do a query for all custom posts who has no value assigned for that taxonomy (i.e. uncategorised). This is what I have so far: $uncatQuery = new WP_Query( ...
0
votes
0answers
30 views

Custom template of page with blog posts list for multi-blog page

I need to use (on my theme) multi blog pages (Posts page). My idea is using page template for it, but I have a problem with getting all posts in template file. Regular loop the_post() from index.php ...
0
votes
1answer
32 views

Why is this coming back as null? Thats wrong. There is one post

I have a category, called events. It is assigned to one post. So I created the following loop: $args = array ('category_name' => 'events', 'posts_per_page' => 4, 'orderby' => 'date', 'order' ...
1
vote
3answers
26 views

Search tags in CPTs

I can't seem to figure out how to include tags in a wordpress search. For example, if I search for 'apple', I would like to get back posts with 'apple' in the title or the content (default wordpress ...
-1
votes
1answer
33 views

Adding css tweak based on page template

I have a parent page that is listing out all of it's child pages. This is done using the below: <?php $query = new ...
1
vote
1answer
77 views

WP_query Date Range results not matching loop

I have written a WP_query with a date range. $args = array( 'date_query' => array( array( 'column' => 'post_date_gmt', ...
1
vote
1answer
48 views

Pagination returns 404 after page 20

I got a paged loop that pulls in 4 posts per page from custom post type. It works great, with the only downside that the pagination wont go over the page/20 everything after that is 404, and the ...
0
votes
0answers
14 views

Inject post into feed

We have a promo post, and if this promotional post is published, I want to inject it into every tag feed that meets our criteria. I figured it would be possible by modifying $query via $query->set(), ...
0
votes
1answer
34 views

Using WP_Query to re-query and sort results using a date?

I'm writing a function to find the users next upcoming event (stored as CPT), chronologically. If I use a normal query and do something like 'post_type' => 'ticket', // another CPT set up to act ...
0
votes
0answers
30 views

Show posts between two Custom Fields date

I'm trying to fetch all the posts from today to next week by using some custom fields inside posts, using Advanced Custom Fields. Everything was working until now, because it doesn't show posts from ...
1
vote
1answer
49 views

Minimising Database Queries when using Advanced Custom Fields

I'm working on a page which lists staff members for a large company and trying to minimise the number of times I'm forced to query the database as it gets quite complex and slow. 'person' is a ...
0
votes
3answers
31 views

Query & the_content() is showing in the header

This post is about two things: All the results of this query are posting to the header of the Page not on the content area as they should. Do you know of a solution as to why this is happening and ...
0
votes
2answers
23 views

Custom Plugin - Query CPT - Display Results

This code is going into a sample Plugin I am creating as a test using CPT and print them to a Page. I have been trying to get print_r() to give me an object. The custom post types are posting - ...
0
votes
0answers
10 views

Exclude posts by a guest author still making it accessible from direct url

How to exclude posts by a guest author from category, archive, search and tag pages but still accessible from direct url. I do not want to delete these posts, but is it possible that they are not ...
0
votes
0answers
25 views

Query posts from multiple post types sorted by overarching menu order

I have three different post types named activity, publication and project. I want all posts from these three post types to appear on one page on my website ordered by an overarching menu position. ...
0
votes
0answers
41 views

WordPress ignoring LIMIT / posts_per_page despite being in wp_query

Using WP query: $myquery = new WP_Query( array( 'posts_per_page' => $instance['count'], 'meta_key' => 'mywp_post_views_count', 'orderby' => 'meta_value_num', 'order' => ...
0
votes
1answer
29 views

How to extract information from a wp_query result?

Background: I'm using a wordpress theme called skt full width. I am modifying their front page slideshow, so that it displays six random images instead of six pre-selected images. I have a custom ...
0
votes
1answer
22 views

How to get to a specific position in wp_query?

Background: I'm trying to display images in a slideshow, and I want to select those pictures randomly from the website's media. The image has a custom field in order to be selected for being the ...
0
votes
0answers
36 views

Proper Array Setup

I'm having real trouble getting this to function right, basically I'm tweaking an array for the related products section of WooCommerce for WP, but it's not really a plugin issue more of a general ...