"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

0
votes
1answer
40 views

Previous/Next Link by Meta Value in CPT

I'm using the following code to paginate between custom post types and it doesn't seem to be using the meta_key or meta_value_num and I can't figure out why. The CPT is set-up to have hierarchal => ...
0
votes
0answers
16 views

How to cancel a custom post type query based on existing cache file

Is there a proper way to greatly restrict the query (or remove it altogether) for a custom post type type-single.php file? Simply stated, for reasons of speed speed speed I've cached all relevant ...
0
votes
1answer
42 views

Can I set my WP_Query to be a Main Query?

When I create a WP_Query it's automatically considered a "secondary query", but what if I replace my main query with a WP_Query? Can I set my WP_Query to be considered a "Main Query"? The reason I ...
0
votes
0answers
45 views

Custom Post Type: Event - Display Upcoming Events for Next 30 Days

I need to display the upcoming events for next 30 Days and sort the same based on custom date field. Below is the code I am using right now but not got any success in hiding old Events and ...
0
votes
1answer
29 views

Displaying Event within two given time frames

I'm trying to display two different posts from my CPT named Events. One is going to be the next event the other is going to be previous event. I've got a metabox called 'Event date' The client at ...
0
votes
0answers
61 views

wp_query display posts based on day

I am trying to get all posts to be displayed on a certain date. For example today Tuesday I want all posts to be displayed. It doesn't matter that the posts were created today (Tuesday) or last week ...
0
votes
0answers
39 views

When WP_Query only returns 1 post, how do I automatically redirect to that post?

I've been searching around for a few hours now and can't figure out how to do this. Seems really simple. I've seen lots of redundant examples on how to redirect to a single post when a search result ...
0
votes
0answers
29 views

Integrating WP_Query with multiple Checkboxes

Ive created a CTP called volunteer_position_cpt ... I've also created two taxonomies for this CPT: volunteer_category (tags) and location_category (tags) My interface: [ ] Category 1 [ ] Category 2 ...
0
votes
2answers
41 views

get_post_meta in WP_Query

I'm doing a plugin to add likes to posts I want to create a table on a page in the plugin to show each post and the number of likes function my_plugin_options() { echo '<p>Table of ...
0
votes
1answer
96 views

Current post in AJAX call is always zero

I have a custom post type named event and a button to load more timeline. I need to arange current timeline item to the left or right depending on his current_post from WP_query object. Ex: if ...
0
votes
1answer
72 views

How to show the posts of some category first, and then all other

How to show the posts of some category first, and then all other posts that does not belong to that category? I have logic that get the category and reorder the posts. But i don't know how to use. ...
0
votes
1answer
36 views

Wordpress query portfolio posts

On my template I have this code <div class="blog_block"> <?php wp_reset_postdata(); ?> <?php $nbmax= 9; ?> <?php $tarali_query = new ...
0
votes
1answer
34 views

Unlimited Page Sitemap Link

I am trying to display all the product links (7000+) of woocommerce, but I get a blank result when doing so. When I set 'posts_per_page' to 2000, it returns a result. More than 2000 returns a blank ...
0
votes
1answer
38 views

Slow getting posts from category

My blog has over 700,000 articles and my category structure as follows: -Cats Cat 1 (ID: 3) Cat 2 (ID: 4) Cat 3 (ID: 5) ... Cat 20 (ID: 22) I took the articles by using the following SQL ...
0
votes
1answer
52 views

Pagination error Wordpress multiple loop

I have multiple loops using wp_query() in WordPress. I want to show the posts from first loop first (post per page=10), and if there are no posts from first loop show, then show the second loop. For ...
0
votes
2answers
75 views

Display single most recent post in category on every page of category archive

I am trying to display a single "featured post" in the archive.php template using a custom query. This featured post should be the most recent post in that category or tag. I'm using pagination for ...
0
votes
2answers
39 views

Modify Search Query if original Query gave no results

I'm looking for a way to modify the search query if the performed query returned no results. Let's say I'm looking for "Opening times", so I go to this URL: http://mysite.com?s=Opening+times Now, ...
0
votes
2answers
98 views

Multiple wp_query loops showing first 5 posts on all pages instead of older posts[Resolved]

I am trying to highlight the newest post in a separate layout and rest of them in a masonry index. There are 5 posts per page and I am getting the newest 5 posts on previous posts pages as well. I ...
0
votes
2answers
228 views

Using DISTINCT in wp_query

I need to create a system where the user first selects the state, then select the city and then see the information of the stores in that city. For this, I created a cpt called store with 2 meta ...
-5
votes
1answer
48 views

custom sort posts in archive/taxanomy page

I want to override the default sort order of posts in archive and taxonomy pages. what hooks should I implement?
1
vote
1answer
109 views

How can I get an array of all IDs from the current queried object?

I am trying to join an array of post IDs together. Right now, it seems my code is creating a separate array for each ID, instead of one array with each ID. This is the code that I have come up with. ...
0
votes
0answers
44 views

Pagination on static Posts page

I'm having an issue with pagination on the static blog page. Under Settings > Reading, "Posts page" is set to a static page. "Blog pages show at most" is set to 10 posts. The first ten posts show up ...
0
votes
1answer
47 views

Search Query that Includes Custom Table

I have a WordPress website that grabs product data from a custom table. I would like to be able to also search from fields in the custom table. Could someone provide a sample query of what this would ...
0
votes
1answer
58 views

How can I include sub-forum topics in a bbpress topic loop?

Out of the box, bbpress shows topics from a particular forum when you are on that forum's archive page. Makes sense. If that forum has a sub-forum, it will link to those sub-forums, but it won't show ...
0
votes
3answers
56 views

How to query posts for custom post type with featured image for first 2 post?

I am trying to write a custom post query for a specific post type in a way where only first 2 thumb/featured-image will be shown & other will be just title & other metadata (i.e the picture in ...
-1
votes
1answer
53 views

How to cache wp_query with pagination using transients?

I have seen examples where there is a fix number of posts to be queried; however, I cant find an example when using pagination. I am trying to figure out how to use transients to cache a WP_Query ...
0
votes
1answer
43 views

Proper way to run wp_query from inside a plugin

I am developing a plugin that needs to make a query of a custom post type and retrieve data and meta data from these posts. But anytime I run that query inside my plugin, no matter what admin new post ...
1
vote
0answers
15 views

Querying multiple post types ensure 1 of each type [duplicate]

If I'm querying more than 1 post type, is it possible to ensure that I will always get at least 1 of each type? $args = array( 'post_type' => array( 'post', 'project' ), 'posts_per_page' ...
0
votes
0answers
86 views

Pagination with WP_Query not working

I have a custom page template on my site, with a WP_Query pulling in a list of posts. I'd like to implement pagination but just can't seem to get it right. Here's the code I'm using blelow, which ...
0
votes
1answer
47 views

How can I base a query off of the current page post type AND a meta value from another custom post type

I have 2 custom post types: Communities and Testimonials. I have a drop down menu in the Testimonials CPT that calls all of the communities. The drop down is using the ID of the community. I have ...
1
vote
2answers
64 views

Multiple filter conditions for WP_Query

I'm having a hard time figuring out how to accomplish this (really simple) task: Get 4 random posts, but only select from the 10 most recent posts. This works great for the random part, but ...
0
votes
1answer
31 views

check if a taxnomy queried in $wp_query?

Is there a way to check if there is any taxonomy that has been queried in the global $wp_query?
0
votes
0answers
63 views

Some images not being returned with wp_get_attachment_image

For some reason this code works on my local copy of a wordpress site but the live site is not working. // WP_Query arguments $args = array ( 'post_type' => 'post', ...
0
votes
0answers
4 views

How to remove a filter that has been added as a function [duplicate]

How can I remove a filter that has been added the following way: // Add the filter before executing the query add_filter('posts_where', function( $where ) use ( $lat, $lng) { return ...
0
votes
2answers
92 views

Nested WP_Query breaking loop

I'm using WP_Query to get all pages without subpages. For each page I'm using again WP_Query to get all child pages of the current page inside the first loop. This all works fine and I'm getting the ...
0
votes
1answer
50 views

Sort posts by activity date

I have a list of posts posted on different dates I can order the posts by date $loop_args = array( 'post_type' => 'post', 'order_by' => 'date', 'order' => 'ASC' ) How can ...
1
vote
2answers
40 views

How to display summary content from a Page (Not a Post) on another page

I created a Page called "About Joe" as a page in WordPress. Then on a different page (e.g. the homepage), I wish to display a summary which includes: a thumbnail the 1st paragraph link to page ...
0
votes
1answer
37 views

Pagination not working with WP_Query (creates links but no page)

The following loop gets all posts within a relevant category. It does generate a pagination URL, but it does not take me there (it just redirects back to the homepage). Would anyone know why? $paged ...
0
votes
1answer
21 views

Custom conditions in wp query

This is basic query arguments . $loop = new WP_Query(array('post_type' => 'project', 'posts_per_page' => -1)); Now I want to pass custom arguments like 1.If it is front page post_type will ...
0
votes
0answers
32 views

Modify taxonomy-$taxonomy-$term.php to include posts from all blogs in multisite

How should I modify the taxonomy-$taxonomy-$term.php template to include posts from all sites in the network? I've been looking into the query_posts method from the Custom Queries Codex article, and ...
0
votes
1answer
77 views

Get the type of an advanced custom field (ACF) in a WP_Query loop [closed]

When reading posts with WP_Query how would I get the data type of an advanced custom field (textbox, date, number, repeater, …) ? My code: $loop = new WP_Query( $args ); $posts = ...
-1
votes
1answer
72 views

WP_Query with tax_query not working

I tried to create a custom query, but no results, it throws me an error. $args = array( 'post_type' => 'product', 'posts_per_page' => 1, ...
0
votes
2answers
61 views

have_posts() execution failure

I wanted to create a loop which displays search results in search.php file. I followed all of the instructions in the WordPress Codex tutorial located in here: https://codex.wordpress.org/The_Loop ...
0
votes
2answers
31 views

How to get any tag ID

I want to exclude a certain tag from my home page not a category only post that hold the tag for example "olive"; I found a function for that which is like this function exclude_tag($query) { ...
0
votes
1answer
116 views

How to get current page nearest parent id?

I am trying to get current page nearest parent id not top-level. For example I have added page like this: Now If I am in Junior Design Award 2013 page I want to get his parent id 765 not top-level ...
0
votes
0answers
58 views

WP Query posts__in not working with array

I am using the following code to generate a specific list of posts with WP_Query $args = array ( 'post__in' => $cookie_array, 'post_type' => 'tyre', 'post_status' => ...
1
vote
1answer
25 views

How safe is renovating $wp_query when doing WP_Query pagination in Page Template

With a lot of search and trial&error, I's unable to do the pagination in a custom page template. I's not actually tired, but frustrated, why the most common err issue is not explained in a way so ...
1
vote
0answers
70 views

Custom post type archive pagination query issue

I'm using the following query to paginate a custom post type archive. The number of posts on the first page is 11 (due to the page layout) and 12 on the following pages. The problem is that while the ...
0
votes
0answers
70 views

Sorting Posts Based On Meta Value Using AJAX

I am trying to short posts on frontpage/archive pages using AJAX. The AJAX call seems okay but nothing displaying. Here is the JS: jQuery( document ).ready(function() { jQuery( ".sbyp" ...
0
votes
0answers
25 views

new WP_Query based on average values of meta fields

I have 5 different meta (numerical) fields for a custom post type and I need to create a query based on the average values from those fields (kinda like a rating system, post with highest average ...