"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

3
votes
3answers
28 views

Why does the_content not work like others for a set post id?

Here's something odd, I want to print out a certain post on any page request, if you have a constant $idnumber of your favorite page/message, then add: $GLOBALS['post'] = get_post( $idnumber ); ...
1
vote
1answer
24 views

How to build a WP_Query using mulitple tags and using AND or OR operator between them

I'd like to craft a query to return posts based on the conditional presence of certain tags. The pseudo query is: return posts with "((tagA OR tagB) AND (tagX OR tagY))". But I'm having issues ...
0
votes
1answer
13 views

Can I customize the WP admin default dashboard content?

Can anyone please submit hooks and sample codes to use in restructuring wp admin menu and the content?
0
votes
2answers
2k 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
47 views

Pagination in html table is not working

I have a custom page template and I found a a PHP snippet that create a pagination in html table. But the code is not working properly. UPDATE: I change the code. But still the code is not working ...
0
votes
1answer
19 views

Show one item per category of a custom post type

I'm having a custom type called portfolio with different categories. I want to display all my categories except one. I only want to show one item per category on my page. I'm been busting my butt on ...
4
votes
3answers
106 views

post__in for get_posts with a dynamic array

I am creating an RSS feed. I have created a table in my database with 400 post id's. I have the rss feed coded I am now trying to link the two so my RSS feed runs only for the list of 400 posts from ...
0
votes
1answer
35 views

How to provide meta_key array to wp_query?

I'm trying to build a wp_query, so far I've managed to get desired result using following query. $args = array( 'meta_query' => array( 'relation' => 'OR', array( //check if ...
2
votes
2answers
798 views

Pagination/infinite scroll with WP_Query and multiple loops

I need that the main page of my site have 3 columns: - The first having the 5 most viewed posts; - The second with the next 5 most viewed posts; - The third with the most recent posts. I don't want ...
1
vote
1answer
30 views

Order by meta_value in WP_Query

My orderby meta_value is not working, so I decided to make my meta_value descending from 5 to 1 instead. I'm sorting out a star rating based on the number of stars. If I set 'meta_value' => '5' ...
0
votes
0answers
26 views

tax_query not working for taxonomy slug

i have one custom post type 'game' and one custom taxonomy 'console', which is shared by 'game' and 'post'. Now I created a new PHP 'taxonomy-console' and I want to separately display posts from ...
2
votes
1answer
1k views

How to filter a dd/mm/yyyy date from a custom field in a query

I'm trying to build a query in order to sort some posts by a date custom field, where the dates are formatted dd/mm/yyyy. It works by querying the database directly with get_results like in this ...
0
votes
0answers
717 views

Loop the posts between two dates selected using jquery datepicker

I went through this link where we can restrict the loop to display the posts only between two dates and it works fine. But if I have a Jquery Datepicker with from and to date, then how can I pass ...
0
votes
0answers
14 views

Retrieving category pages from subcategory returns empty sets

I've a category overview page. It shows its subcategories. These subcategories have subsubcategories which are pages too. I'd like to retrieve those (title, permalink and excerpt) but so far my ...
0
votes
1answer
29 views

WP_Query with multiple orderby NOT working with ASC and DESC, what's wrong?

I have a query with multiple orderby params in a custom page that I am having difficulty getting to work. The query is to return posts with either tag-AAA or tag-BBB tags. And I'd like to sort it ...
0
votes
1answer
19 views

Get posts of an specific term of a custom taxonomy

I'm new at Wordpress development and I was wondering (and trying to solve this) for a long time, so maybe you can help me. My WP use a custom post type named Products. And there is a custom taxonomy ...
4
votes
1answer
45 views

Include post id[s] into WP_Query()

I'm assigning some posts to some users whom are not the author of those posts. Typically private posts are visible only to the post authors. So, if the author has 3 posts, on his logged in edit.php ...
1
vote
1answer
22 views

Return Taxonomy/Term Information with Posts (WP_Query/get_posts)

Is it possible to return taxonomy/term information for posts along with the posts themselves when querying with get_posts? I have around 150 items I am querying so I don't want to loop and pull each ...
2
votes
1answer
878 views

Get Recent Posts by Date in Multisite

Everything in explanation is about CDTuts I've created a WordPress Network and I want is to get the recent posts from all of the selected subdomain blogs. I need to get the latest All organized by ...
0
votes
0answers
24 views

Is there a global page/post/product/anything ID?

I am working on compression plugin and need to save compressed styles in to a file. Compression process is done but I need a unique page ID for any WP page in order to save and name the compressed ...
1
vote
1answer
22 views

Can't get order_by meta_value_num to work properly

This query is working ALMOST as intended, but for some reason I can't get it to order by the custom field opl_submission_tempo. That field is set up to be a number, so I'm not sure where I went wrong ...
2
votes
1answer
986 views

ACF Relationship Field Search Filtering

I am trying to assign relate posts using the ACF relationship field. It has typeahead search to search by post titles. I would like to add meta_data search to the ACF relationship search. This ...
2
votes
1answer
74 views

How can i make WP_Query return post image and categories?

I have a sidebar widget that will display related posts based on a custom meta field. The query works, but its very wasteful. All i need is the post title, featured image and the categories of the ...
0
votes
1answer
748 views

Displaying the category name of a custom post type

So I have a custom query, in which I'm displaying some results posts of a custom post type called "staff". This custom post type is linked to a custom taxonomy called "department". I am able to ...
-3
votes
0answers
11 views

infowindow display incorrect information, how i can correct it? [closed]

/style.css"> <div id="map"></div> <script> function initMap() { var myLatLng = {lat:47.047485 , lng:28.863210}; var mapDiv = document.getElementById('map'); ...
0
votes
1answer
14 views

WP_Query returns empty if meta_query has more than 7 values

I have a custom loop to display a custom post type 'properties' . The idea is to search properties based on different search parameters selected by users. Now the weird problem I am facing is that if ...
0
votes
0answers
18 views

Combined filters

I have a problem and i'm really stuck on this one. I have a small 'woodshop' and i want people to filter the results. The case: When i check multiple brands, the types should be updated. But when i ...
0
votes
0answers
11 views

How to search based on meta keys

I am trying to search custom post type based on meta keys but have no success so far I only have one post in this custom post type but no success. Here is the code. $args = [ 'post_type' => ...
0
votes
1answer
35 views

Content not displaying on paginated page

So, it's taken me most of the day to get my query working (some days I feel like I don't know WP at all) and then I was getting a 404 error on paginated pages which I've since fixed but now I'm going ...
0
votes
0answers
17 views

Display Posts in Admin Page

I create a admin page. Now I need to display posts in that page. Should I use WP_Query or get_posts()? (Pagination should be there) Note : I have read When should you use WP_Query vs query_posts() ...
0
votes
2answers
1k views

Pagination doesn't work

I created myfile.php with the following content: global $paged; if ( get_query_var( 'paged' ) ) { $paged = get_query_var( 'paged' ); } else if ( get_query_var( 'page' ) ) { $paged = ...
-1
votes
0answers
26 views

WP Query ACF Custom field

So I created a post type named 'client' and I used ACF to create a custom field 'logo' . Initially it will load 8 clients then there will be a 'see more' button which will load another 8 clients. I ...
2
votes
3answers
414 views

Minimising number of queries on a page when using Advanced Custom Fields

I'm currently working on a site where there is extensive use of the popular Advanced Custom Fields plugin. However, as a result the page loading time can be quite slow, especially when using the ...
0
votes
2answers
24 views

Custom MySQL query to pull out Advanced Custom Fields?

I'm trying to modify the My Wish List plugin so that I can retrieve some custom fields (I'm using the Advanced Custom Fields plugin to create my custom fields in the admin end). The plugin uses the ...
1
vote
1answer
667 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 ...
1
vote
1answer
957 views

Auto Populate Custom Field with Complex Value That Increase by One?

Can somebody help me to sort this? I am using WP 3.5.2 and I have "Orders" post type where purchase_order custom field is located. This is the sample of purchase order record: POCOS20130051 PO - ...
0
votes
0answers
16 views

Query Posts by post_meta using WP_Query (data saved as array with keys)

I am working on some project where i need to create class (like karate etc...). My question is, how can i work with WP_Query to Query all the posts by post_meta where the key "day" is "1" for ...
1
vote
1answer
557 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 ...
1
vote
1answer
3k 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 ...
2
votes
1answer
31 views

Listing posts with wp-cli

I use wp-cli to export some posts from my WordPress database. I'm trying to understand the differences in behavior that are exposed in the example below: $ wp post list --path=/var/www/home-web ...
0
votes
0answers
9 views

Use tax_query to sort posts by most “categories in common”

I know I can use tax_query but what I really want is to sort them by "most categories found that are equal" Is there a way to do it easily?
3
votes
1answer
41 views

WP_Query orderby one custom field then another in one query

I hope I can explain it properly so here we go! I have a property listing page that should be ordered by the date a listing was posted (data comes form an API so it's not the WP post date) and then ...
1
vote
1answer
23 views

Orderby the sum of several numeric custom meta fields

I would like to know how I can do the following in the simplest way. Say I have several numerical meta fields (more than two). I want to be able to orderby the sum of those meta fields. But it is ...
0
votes
2answers
518 views

WP_Query - meta fields numeric

I'm having trouble with the code below. Attempting to do a query against meta data stored with the posts, in the mls post type. I think I know what the issue is, but not how to fix it. I am ...
2
votes
2answers
1k views

Using tax_query creates a 1 = 0 or 1 = 1 in $wp_query->request

This is my first attempt at modifying the main query using the pre_get_posts action/filter This is the function currently hooked to it: function advanced_product_search_filter($query) { ...
0
votes
1answer
1k views

Group posts by meta_key

I have a Problem with grouping meta_values. The Query looks for posts with the meta key "company". I want a unique listing of the colors like: blue red yellow array_unique was not successful and also ...
0
votes
2answers
3k views

Display one latest post from multiple categories

This should be very easy, however for some reason I can't find a working snippet anywhere on the web.. I basically need to display one latest post from 6 categories (can be changed to 7,8, etc etc) ...
0
votes
0answers
24 views

Cast woocommerce events date meta_value with wrong format in WP_Query

I'm using woocommerce events plugin to sale tickets in a client site. The client wants to display the next 3 events after today in the home page. I have created this code: $args = array( ...
0
votes
3answers
21k views

How to limit the posts

I have a new question, how can I limit the amount of posts coming out of this query? I only need 7 <?php $newsposts = new WP_Query('cat=restaurant'); if ( is_front_page()) { echo '<h3 ...
2
votes
2answers
830 views

Pagination problem after WP_Query with tag filtering

I have a problem with a custom WP_Query. I want a page with all posts with a specific tag. This is the code I'm using: <?php //save old query $temp = $wp_query; //clear $wp_query; $wp_query= ...