"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

5
votes
2answers
77 views

Whats the difference between post_limits and pre_get_posts?

Because of the lack of documentation about post_limits, its hard to learn more about this function and when to use it. Never used it before or seen it used so maybe its not to be used? function ...
0
votes
3answers
23 views

wp_query get attachments in larger size

I'm using wp_query to get all attachments, and it works, but I wonder how could I get attachments in full size because this query returns images in medium. <?php $args = array('post_status' ...
-1
votes
1answer
29 views

Showing specific post in order of array wp_query

I have displayed some specific post ID's in a custom template with wp_query. I am struggling to figure out how to make these in order. I want to show 1682 first and 1540 last. They do not show this ...
0
votes
0answers
14 views

I wan to process the following js to process the AJAX Request on my function to calculate author Total Post views

This is my Ajax Handler function function get_total_post(user_ID) { jQuery.ajax({ type: 'post', url: ajaxforall.ajaxurl, cache: false, data: { action: ...
0
votes
2answers
598 views

wp_query within function within wp_query

I have a query which looks like this: $args = arguments for the query $query = new WP_Query($args); while ($query->have_posts()): $query->the_post(); $post_id = get_the_ID(); echo ...
0
votes
1answer
348 views

All blog posts are not showing up

This post may already exists but I just missed it in how I searched for it. Here goes. I have recently changed my blog back to the Genesis Framework. I am using the Nameless child theme. These are my ...
0
votes
0answers
33 views

Most view topic posted in last 24 hours

I have this query to get most post views. I want to retrieve top 3 most viewed topic which are posted in last 24 hours. If the website gets less than 3 topics from last 24 hours it has to retrive the ...
0
votes
0answers
22 views

WP_Query to show post from a category OR custom field - Not 100% answered

Regarding answer provided by birgirethis to this post: wp-query-to-show-post-from-a-category-or-custom-field I found one issue with your solution. The two inner joins (term_relationships and ...
3
votes
1answer
80 views

WP_Query to show post from a category OR custom field

I am looking for a way to show posts that belongs to a specific category or if they have a custom field. If I specify both parameter 'cat' => '9' and 'meta_key' => 'featured' in query arguments ...
0
votes
2answers
39 views

Force Wordpress to be more random

I use a random wp_query to load 3 posts from over 600 posts in total with this query. <?php $args = array( 'post_type' => 'post', 'cat' => ...
0
votes
1answer
19 views

Display post meta conditionally based on it's value

I have a custom field that's a radio button with 3 choices (yes, no, other). What I'd like to do is the following: [If custom field value is yes] Display something here [elseIf custom field value ...
0
votes
0answers
28 views

Correct Way To Run Multiple Queries Sharing Some Base Data

I need to run three queries on the same page. The 'core' query is the same all three times - selecting posts in a particular taxonomy. I then need to run three queries on that subset looking for ...
0
votes
2answers
1k views

Unable to combine “search value” and “tax_query” using WP_Query

This is my function in my template's functions.php. The problem is that this is working: function ajax_search_action_do(){ global $wp_query; $search = $_POST['search_value']; $country ...
0
votes
1answer
1k views

Action hook “wp_insert_post” works but not for last imported post

I want to run a custom function whenever posts are imported to my custom post type. I am currently running this code - function on_post_import($post){ global $wpdb; $results = ...
0
votes
1answer
33 views

(How) Can I use 'wild cards' on the left hand side of an array argument?

I've spent all day trying to work out how to do this, and have only advanced a little - and that's mainly in finding methods that DON'T work. Am hoping someone knows something or can see something ...
1
vote
1answer
65 views

WP_Query doesn't get sticky post at the top, when used in a page template

I'm creating a theme in which I've created a page template called page_default-blog.php to be used for creating a blog page. In this file I have the following code: $paged = (get_query_var('page')) ? ...
1
vote
1answer
65 views

Prevent duplicate post from dynamic multiple loops

I was trying to list 20 recent posts, and put a post from custom post type on every 5th item. So it's like: Post Post Post Post Post Custom Post Type Post Post Post Post Post Custom Post Type .. and ...
0
votes
1answer
18 views

how to query for meta_value have array

I have array in post_meta like this: array( 'option1' => 'true', 'option2' => 'true', 'option3' => 'false', option4' => 'true', 'option5' => 'false' ) and I would ...
0
votes
1answer
808 views

Search.php - return number of results but cannot loop through

I have a following search.php page (this is just the code required for problem presentation). Why is my $total_results returning a number of posts found, but when I do a loop though it always print ...
0
votes
1answer
32 views

Reset Wordpress Post Query to default

i am in a situation, i am creating a custom wordpress theme but i am stuck over something. in my index/home page, firstly i am displaying 6 posts by category like below <?php $posts = ...
0
votes
0answers
14 views

Infinite scoll on search page not working

i have implemented infinite scroll feature to my custom wordpress theme which is working fine on home/index page but i search page of my theme the infinite scroll is not working properly. The Problem ...
0
votes
1answer
446 views

How to query posts by meta keys AND under specific category?

The scenary: I'm working in a review system for WordPress, a game review website. It uses default posts, that when under "review" category, shows the review's meta fields (from ACF plugin). It's ...
0
votes
1answer
489 views

Querying A Post That Includes Two Taxonomies Using JSON Rest API

I'm using the JSON Rest API plugin (https://wordpress.org/plugins/json-rest-api/). I have two custom taxonomies with one term each: Inner Part Categories Eye Symptoms Categories (Man) Broken Bone ...
0
votes
1answer
476 views

Site not getting correct featured image from my query

On the home page of my site I have a series of tiles that link to various parts of the site. One tile links to the blog and I have written some code to pull the latest post with an image attached to ...
0
votes
2answers
59 views

Show only one post for each author ( Page loads too slow )

I want to show only one latest post by each author and found this code that it working. However, it takes too long to load the page since I have over 100K authors and 100K posts in database. How can I ...
2
votes
4answers
1k views

post_type is ignored by WP_Query when 'tag' argument is included

I've created a function to call in a page template, inside of which is the following query: $custom_news = new WP_Query(array( 'post_type' => array('post', 'resource', 'job'), ...
0
votes
2answers
2k views

meta_query on a date range using an array of values

How can I do a query to return the post if the custom field array contains a date that is within the specified range? The query below is basically what I am after but it does not work... // the ...
0
votes
2answers
30 views

pass parameters through variable to WP_QUERY

I'm trying to use the plugin PrivateContent to limit access to certain pages/categories. I have a function (getAllowedCategories()) which reads PrivateContent access levels for the current user and ...
1
vote
2answers
16 views

Get rewrite result

Quick simple question. How would I get the result of a rewrite in wordpress? For example I have: www.some.website.com/some/parameter How would I get the end result that WP processes? Aka, the ...
8
votes
5answers
23k views

query_post by title?

is it possible to create a loop of posts using WP_Query or query_posts using the title? ie $args = array('post_title'='LIKE '.$str.'% '); $res = WP_Query($arg); // the loop... // trying this ...
0
votes
1answer
33 views

Is it possible to add query parameters on the archive page?

I have a custom post type (works), and an archive page (archive-works.php). I would like to hide the non-public posts from the archive page, so I added a custom meta box. I also modified the query to ...
0
votes
1answer
115 views

Ajax load more posts - WP_Query parameters not working

I'm trying to replace the standard WP pagination with an Ajax load more posts button. I'm basically following the code from this question which for the most part works well. Here's the relevant ...
1
vote
3answers
30 views

Not getting author rank when using return

I am implementing a section in my website to get the top 5 authors using this code. function ranked_authors(){ $usrs = get_users('role=contributor'); $countarr = array(); foreach ($usrs as ...
1
vote
1answer
389 views

Too many posts cause slow load when paginating

I have about 10k posts and I made a page that lists all posts but it is paginated every 54posts. It gives 131 queries in 6.730 seconds which is pretty slow to load. Is there a way to make it load ...
0
votes
2answers
417 views

SQL returned by Wp_Query has wp_posts.ID = -1

I have a custom loop based on these arguments (below), and for some reason when it's run, the SQL returned has this fragment: ... AND wp_posts.ID = -1 ... And I get no results from the db. If I run ...
2
votes
1answer
429 views

Display recent posts from the same category as current post in sidebar

I'm using a modified version of Twenty Twelve and I'm trying to display recent posts from the same category as the current post (except the current post) in the sidebar. I started this way but ...
0
votes
1answer
494 views

WP_Query post at custom position

Lets say I have a custom query which based on two custom post types: $wp_query = new WP_Query(array( 'post_type' => array('post-type-1', 'post-type-2'), 'post_status' => ...
0
votes
1answer
2k views

wp_query->max_num_pages always returns 0 on custom post type

Hi there I am developing a theme where I have to load some posts with ajax, in my index page everything works properly, the problem is when I need to use it on custom post type, I pass the values for ...
0
votes
1answer
22 views

Querying by taxonomy vs Querying by Custom fields Speed Comparison

I'm developing a listing portfolio for our project. (Basicaly yachts with their type, size, price, cabins, draft, build year, refit year etc.) I should filter them according to type and sort by ...
0
votes
0answers
22 views

How to make the default Wordpress search return borader results

I'm displaying the results of a search query on one of my custom pages. The query is simple: $shopArgs = array( 's' => get_query_var('s'), 'post_type' => 'products', ...
5
votes
2answers
74 views

Exclude a category if post is only in that category using wp_Query

I have two categories Category1 (ID = 1) Category2 (ID = 2) I want to display posts Which are in Category2 and in (Category1 + Category2). If a post is only in Category1 then it should not ...
0
votes
1answer
45 views

Exclude posts that only have the 'Uncategorized' category [duplicate]

I want to exclude posts that only have the Uncategorized category (i.e. category id 1), but if a post is (erroneously) categorised as "Uncategorized" but also has other categories, I want to include ...
14
votes
5answers
27k views

WP_Query with “post_title LIKE 'something%'”?

I need to do a WP_Query with a LIKE on the post_title. I started with this regular WP_Query: $wp_query = new WP_Query( array ( 'post_type' => 'wp_exposants', ...
0
votes
0answers
49 views

WP_Query custom field pass the post id

I'm using WP_Query with ACF(Advanced Custom Fields) I'm building a news portal, and I'm trying to pass related stories from 1 post which is top_story = true. In another WP_Query I want to print the ...
1
vote
0answers
34 views

WP Query to have sticky posts first, with pagination and having a joint 'posts per page' arg with main loop

I am building a Wordpress site and have come to a bit of a wall while using a WP_Query, it started out quite simple but then sticky posts got thrown into the mix and it's becoming a bit harder to ...
1
vote
1answer
510 views

How to reduce the number of queries?

I have meta key "Due" for posts....if a post has expired (past the current date or not equal to it) then it will not be displayed in the count. This is my code, which works perfectly. My only problem ...
0
votes
1answer
54 views

Reduce or prevent calling of update_meta_cache

My theme calls the update_meta_cache() function 58 times per page! This function appears to run the following query based on the post in question: SELECT post_id, meta_key, meta_value -> FROM ...
0
votes
1answer
73 views

Using AJAX to return search form results

I'm trying to take user input from a search form, build a query based on user input, and then return relevant posts using AJAX. Right now, the form builds the select dropdowns properly. The form ...
0
votes
1answer
29 views

Show posts of an advanced search form

I have created a search form with multiple fields, and I want to display the posts that match all the fields inserted in the search form. For example, if I choose T-shirt && Red && L, ...
0
votes
0answers
10 views

alter $post variable in main query as soon as possible [duplicate]

I'm using WP with WooCommerce. For some purpose, I want to load a predefined static page (e.g. with id=5) whenever the user enters a product page (e.g. www.mysite.com/?product=my-product), by ...