"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
27 views

Loop categories by recent post

Im looking for a way to loop through categories and then display the recent posts for each one in a container but I need a way to sort the categories by which ones have the most recent posts So if ...
0
votes
2answers
24 views

How to set an alternate posts_per_page value for default queries in different templates

I have a WP site with multiple post types. Posts, products w/taxonomies. I have my WP Default posts_per_page setting at 10 in the admin. I want to keep this setting as the blog would be best at 10 ...
1
vote
1answer
36 views

Multiple endpoints in one URL

I am trying to add multiple endpoints in one url like: http://localhost:1000/manage-lead/lead_id/1000/product_id/123455 But this way the query var lead_id is equal to 1000/product/123455 and not ...
1
vote
1answer
54 views

Query all posts if multiple meta key don't exist

I'm trying to get all posts that don't have a meta ket that starts with aa_. I can do it this way $args = array( 'posts_per_page' => -1, 'category__in' => 23, 'meta_query' => array( ...
0
votes
1answer
61 views

Pagination for search results of custom post type [duplicate]

I'm trying to display numbered pagination for search results of a custom post type. Basically a search form allows users to search a custom post type by 2 different taxonomies and then the results are ...
0
votes
1answer
32 views

How can I create another instance of my custom shortcode

I've created a custom shortcode which takes category slug and number of posts as parameters and creates a loop with WP_Query and outputs the posts from db. But I'm unable to use it more than one time ...
0
votes
2answers
36 views

WP Query with multiple post types ordered by custom meta date then published date

Two post types blog and events. I want to list in the same query but order events by their event date and blogs by their published date: $args = array( ...
0
votes
1answer
24 views

Pagination in WP_Query?

I am using a WP_Query to display posts from within a category and a custom term selected ("fitness visibility" inside category "articles") My code: <?php $catquery = new WP_Query( ...
0
votes
1answer
33 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 ...
1
vote
1answer
46 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
62 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
45 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
2answers
67 views

Fetching $_POST from Page Template into functions.php

I'm having an issue with the order WordPress is loading page templates and functions.php. I have front-page.php which has $_POST['sort-by'] allowing users to sort posts using a drop-down menu. It's ...
0
votes
1answer
78 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 ...
0
votes
0answers
51 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
66 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 ...
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
65 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
96 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 ...
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
2answers
49 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
91 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
37 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
40 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
2answers
62 views

Conditional posts in WP_query for search

I have a custom post type that im trying to limit results in search. The CPT is a deal/coupon, with a start and end date for each of the deals. What I'm trying to do is only show these posts in ...
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, ...
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 ...
4
votes
5answers
169 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
57 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
97 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
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 ...
0
votes
1answer
61 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
124 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 ...
0
votes
1answer
33 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
35 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
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
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
59 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
46 views

Group by custom field value (start and end times)

I have the following loop that is outputting a schedule for a conference. At the moment it's looping through a custom post type, grabbing the info, then outputting it in a block. So essentially each ...
0
votes
0answers
34 views

Custom filtering/search

I would need to do custom search for my archive page that would filter based on metakeys, freeword and couple select options. Probably my best option is to use the normal wordpress search ...
9
votes
3answers
486 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?
0
votes
1answer
51 views

Nested array issue in meta_query

I am using following meta_query to search blog post according to following search criteria, search logic : if expire date set, check the expiry of the post, otherwise just include it if ...