"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
votes
1answer
2k views

Why does 'exclude_from_search' exclude a custom post type from WP_Query?

In WP 3.1, it appears that setting 'exclude_from_search' = TRUE for a custom post type excludes the post type not just from searches on the front-end, but also from any post query using 'post_type' = ...
0
votes
2answers
3k views

Filtering a WP_Query meta_query by numeric values isn't working

That was a very dense title. I have a custom post type "event" which has a Date/Time picker field "event_date" thanks to the Advanced Custom Fields plugin. This Date/Time picker saves a UNIX ...
1
vote
1answer
45 views

How to do a wp_query with two acf-fields, sorting on one of them

I have two Advanced Custom Fields, footnote and date_edited (a datepicker-field). What I want to achieve is to run a wp_query where footnote is not empty. The output I want sorted based on ...
0
votes
2answers
2k views

Accessing the post content with WP_Query

I have the following code from a template to view get the post information: <?php $args = array( 'post_type' => 'post', 'posts_per_page' => $count, 'paged' => ...
0
votes
1answer
32 views

Adding a html class based on post count

I'm creating a grid of columns and need to add a css class to each column at the end of the loop based on the amount of posts returned so it returns something like this: <div ...
0
votes
1answer
952 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
2answers
60 views

How to display post list in a table layout (multiple queries in single loop)

I am setting up an events page for my website. This page is using a loop to display a list of acts performing at different venues month-by-month. When a viewer comes to the page, they use a simple ...
0
votes
1answer
43 views

Filter posts of custom post type by meta key in (List All Section)

How can I filter the posts which are displayed on the admin list all page of a custom post based on the value of the a value. So far I know how to do the following anywhere on the front end: $args = ...
0
votes
1answer
76 views

WP_Query posts with comments only

I need a flexible solution to put out a list of posts with comments. I'm trying to get this solution to work, but have no luck: http://wordpress.stackexchange.com/a/219216/91757 I'm always getting ...
0
votes
1answer
20 views

order posts by `meta_key`, Does not display posts that does not have `meta_key`

I'm using this query orderby meta_key for show posts. if one of the posts does not have vip_row meta, So not shown; Is it possible that if one of the posts does not have vip_row meta to be ...
2
votes
3answers
7k views

How to use the_posts_navigation for wp_query and get_posts?

WordPress have the_posts_navigation function since 4.1.0. But I don't know how to use with wp_query or get_posts. the following code is in a template file of page.wp_query method: <?php if ...
0
votes
0answers
48 views

WP_Query meta query not returning results as expected

I'm trying to run a get_posts query to determine if a users ID is either set as a meta key value or is included within the array of another meta key for an event on a given date. I am passing ...
1
vote
0answers
18 views

Query with relation and one without relation using multiple taxonomies?

I'm trying to use one query for two queries, one with an and relation and one without without having to do multiple queries and loops, is this possible? <?php $args = array( 'post_type' ...
0
votes
2answers
65 views

Pagination Not working on Home Page with 2 Query

I have two loops in home page (index.php) <?php $args = array( 'post_type' => 'post', 'posts_per_page' => 3, ); $another_query = new WP_Query($args); if( ...
0
votes
1answer
27 views

Query custom post type by custom taxonomy (category slug)

I've followed several related solution. But I'm still facing the problem. I've applied the following code for my custom post query by taxonomy (category). But it's not working. I think my problem with ...
13
votes
2answers
4k views

Using pre_get_posts with WP_Query

I was reading Stephen Harris's excellent answer to this question regarding the use of WP_query(), query_posts() and pre_get_posts. He says "pre_get_posts is a filter, for altering any query. It is ...
22
votes
3answers
5k views

Should I use Pre Get Posts or WP_Query

I have the following query which I call in my taxonomy.php template via query_brands_geo('dealers', 'publish', '1', $taxtype, $geo, $brands); This function works perfectly. However after reading ...
0
votes
0answers
20 views

Custom Field - Save Pageviews For Specific Time Period

I have a custom field called page_view to save page views. Now I need another custom field called page_view_last_24_hour to save page views in last 24 hour. Is it possible to use custom field to ...
0
votes
2answers
61 views

How order posts from category by date and comment count?

Just like in topic I try to order posts from category by date and comment_count but code below doesn't work: <?php //get post from current category $category = get_the_category(); ...
3
votes
1answer
93 views

Calling a wp_query $posts causes a 500 error

I had a very basic wp_query, below: // WP_Query arguments $args = array ( 'post_type' => array( 'post' ), 'post_status' => array( 'draft' ), 'posts_per_page' ...
0
votes
1answer
30 views

How To Call WP_Query From A Subdomain?

I have a PHP script running in WordPress, that uses a WP_Query to get the posts from one of my subdomains and return it as a JSON string. The script only receives the post data if I call it using the ...
6
votes
1answer
683 views

Wordpress get_posts function, 1300 lines long

I'm just getting started learning about the WordPress Core. WordPress's codebase is the first large codebase that I've looked thoroughly into. The get_posts method in wp-includes/query.php is 1300 ...
1
vote
0answers
917 views

Multiple keyword search

I have a custom search where I want to enter a keyword or phrase into the search box, and then by pressing enter it adds it to a 'search storage' (already coded, see below). Asume I have 3 posts, one ...
0
votes
1answer
41 views

Wordpress Bootstrap Grid

What's the best way to create a grid layout using bootstrap, or see link below http://v4-alpha.getbootstrap.com/examples/carousel/ displaying three different headings, should i use wp-query or, ...
0
votes
0answers
30 views

Customize add to cart

I have created a page of getting custom values from the customer but the process will be taken place in steps like select lesnes click next select product frame click next so all the information ...
0
votes
1answer
76 views

2 Loops on one page - pagination of 2nd loop ignore array of excluded posts

I have 2 loop on one page. First one shows 11 recent posts in rand order and pushes each post ID into do_not_duplicatearray. $argsRandom = array( 'numberposts' => 11, 'fields' => 'ids' ...
0
votes
2answers
47 views

Display specific page (that is child) content on parent page

I have problem displaying child page content on parent page (both static). I can display other page content but only if on same level. It dosent work in relation parent - child. <?php ...
1
vote
4answers
88 views

How do I query for posts by partial meta key?

I have a function that stores the "like" status for a post as post meta. I want to associate that "like" with the user that liked it, so I setup a custom field called "like_status_{user_id}" (where ...
0
votes
1answer
35 views

active link for most recent post on vertical tabs

I'm trying to add the css class .is-active to my vertical tab links inside my loop. By default, the page loads the most recent post first. How can I make most recent tab/post active with .is-active? ...
0
votes
1answer
39 views

How to allow Readers to Select Post Order?

I added a select field for every category, tag archive page. Sory By Post Date Sort By Post Modified Date Sort By (custom field) When a reader select any of above how to load posts according to ...
0
votes
0answers
25 views

Insert single CPT items every x posts of another CPT

I know there is something similar already discussed here, but I cannot seem to get my head around this to fit my current project and needs. For a portfolio, on a query of portfolio entries (custom ...
0
votes
0answers
31 views

How to allow users to select post order in any archive page?

I have build a something like forum using WordPress (Not using plugins). Now I want to display select filed to select user to post order ( Most recent posts, most active posts, most votes post, ...
4
votes
5answers
162 views

Return parent post with its children using WP_Query?

In some cases it might be useful to use multiple post & page parameters in your WP_Query object. In my case, I would like to display children of a parent page including the parent page itself. ...
0
votes
1answer
55 views

Extending WP Query: Custom geolocation meta values work, but tax_query breaks

I've built a custom query for geolocation searches. I'm saving lat and lng within each custom post type as a meta value. My query extension returns results successfully when lat and lng are the only ...
0
votes
1answer
90 views

Wp_query WooCommerce products

I'm currently developing an e-commerce store using Wordpress and WooCommerce. I'm planning on creating a basic product filtering system and was wondering if it's possible to wp_query the results shown ...
0
votes
0answers
31 views

WP_Query order by number of likes

I'm trying to configure WP_Query to order by number of likes. I have a custom table called 'likes', which records which liker (user ID) likes which post: id | liker | post_id 1 | 11 | 120 2 ...
0
votes
2answers
228 views

WP_Query search for whole words

I'm searching for science related terms. Here's what I need my query to do. If someone searches 'bio', they should not get results for terms 'biology' but they should for 'bio science'. I need the ...
0
votes
0answers
43 views

How to initialize a new WP_QUERY object in custom wordpress page?

I am new to PhP and Wordpress development so this might seem a completely newbie question. I am testing the wordpress development platform and have created a new PHP blank page in a theme directory ...
6
votes
2answers
25k views

How to print the excuted sql right after its execution

I am searching for a way by which i can print the executed sql query just after the : $wpdb->query( $wpdb->prepare("INSERT INTO tbl_watchprosite ...
0
votes
1answer
59 views

Why do I have to use pre_get_posts with custom WP_Query to reset posts_per_page?

This makes no sense , I am using custom query in archive.php to do masonry layout. $term_id = get_queried_object_id(); $paged = 1; if ( get_query_var('paged') ) { $paged = ...
-1
votes
1answer
117 views

How to show all posts of specific custom post type with their custom fields values?

I am trying to get the list of all posts with post_type "staff" along with custom fields assigned to this post_type. Custom fields were create with help of ACF. I've tried both: $query = new ...
3
votes
4answers
12k views

How to get Page/Post Gallery attachment images in order they are set in backend using WP_Query()?

I am trying to retrieve all the images from the Gallery of a page in the order they are set in the backend. So far I have: $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query( ...
0
votes
1answer
29 views

Display post from a date range from custom field

I currently have a custom post type that has two major custom fields that are need for the query. The 'score_time' field stores time of a score. Example: 12:20 The 'score_date' stores the date the ...
0
votes
0answers
34 views

Can't combine 'post' and custom post types in same query

I have a totally weird situation! For me, in Google Chrome; this query (used to generate a slider on the front page) produces the expected result (content from all four post-types): $args = array( ...
0
votes
0answers
28 views

+ 0 in ORDER BY

My $args: Array ( [post_type] => course [showposts] => 99999 [orderby] => meta_value_num [order] => DESC [meta_query] => Array ( ...
0
votes
0answers
34 views

Using WP Query to combine posts and taxonomies

I'm trying to use wp_query to create an index of posts, but I want to combine post titles and a custom taxonomy to create this output on the page: Cheese (a single post title, arranged ...
0
votes
0answers
58 views

WP_Query and Infinite scroll

I'm using the infinite scroll jQuery plugin in all the archive pages but, that's strange, is working just in a few of them. Here an example: this is working and this is not. As you can see, the script ...
3
votes
1answer
62 views

Nested query inside Logical operator OR not working in meta_query

I've been trying this for hours now and I have searched and haven't gotten a clue. I am trying to make a nested query with OR operator as a parent and AND operator inside it as child. The page keeps ...
0
votes
1answer
47 views

WordPress: Cron locking and Queue

I have some CPU intensive scripts that I don't want to run concurrently. Every now and again the scripts will overlap and crash the server. Already at 2GB and the mysql container still crashes. I ...
8
votes
3answers
463 views

$GLOBALS['wp_the_query'] vs global $wp_query

What is the difference between $GLOBALS['wp_the_query'] and global $wp_query? Why prefer one over the other?