"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

2
votes
1answer
81 views

Custom Field sort not working (WP 3.8.1)

I am trying to sort a custom wp_query using the date format YYYYMMDD (php: date('Ymd') ). This will not be regarded as date field, but rather as a numeric one stored in custom field. My WP-QUERY code ...
0
votes
0answers
16 views

Custom search result

I've tried to google it for several time but i couldnt find anything clear. I added a select field in the searchform.php, but if the user choose one of the options, i dont know how to show it on the ...
1
vote
1answer
41 views

WP_Query returns random number of posts

There's a file called inform.php included in index.php, single.php and single-news.php with the below query in it: <?php $arr = array('cat' => '12837', 'posts_per_page' => '22'); ...
1
vote
0answers
15 views

2 weeks ago from meta query meta value

This is my meta query within my posts query. 'meta_query' => array( array( 'key' => 'rw_membership_ends', 'value' => ??????? ...
0
votes
0answers
54 views

Pagination not working on template page

I have the following code, but it is not working. if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } elseif ( get_query_var('page') ) { $paged = ...
1
vote
3answers
121 views

Why WP_Query::is_date() returns false when 'date_query' argument is set?

WordPress 3.7 introduced 'date_query' argument for WP_Query. That's pretty useful and allow very complex date-based queries, however something strange happen when using WP_Query conditional methods ...
1
vote
1answer
40 views

Show list of authors with latest post NOT older than a month

I found two bits of code. One gets me posts NOT older than a month the other bit gets me a list of authors and their custom fields, names, etc. Can someone please help me integrate the two. One runs ...
0
votes
1answer
18 views

Can't order the query result as given posts id's array

I want to order a query result by the same order as the post id's array given. E.g. I have: $arrayPostsIds = array(30,5,17,10); and I want to get the posts in that order. So after trying this: ...
4
votes
2answers
95 views

Order by optional meta key?

I'm building the sorting functionality for a custom post type, and I have a custom meta value for "Featured" posts. This value is set when you tick the checkbox, otherwise it is not set. Using the ...
0
votes
0answers
46 views

Why WP_Query in functions.php is not working when get_posts works?

I have following code in my functions.php. When I try to add new post_type (e.g. post,lawyers) it fills excerpt,slug (this affects in permalink structure), other metaboxes from first post of lawyers ...
1
vote
1answer
34 views

How to sort a custom wordpress query by combination of meta values?

I'm trying to build a custom query that's a combination of custom key values. For example, with the code below I'm able to sort my posts by how much money they've received (paidusd) and how much tips ...
0
votes
1answer
43 views

Get the original menu item name string instead of the label

I am building a hierarchical menu of custom taxonomies and their related posts using wp_get_nav_menu_items as follow: if( $locations = get_nav_menu_locations() && ...
0
votes
1answer
27 views

Remove Post if Advanced Custom Field is checked to fix paging

I'm trying to setup a query that filters through posts and removes ones that have an ACF field "archived" checked. Post queries are pretty foreign to me. ...
0
votes
1answer
43 views

Writing less unnecessary code with WordPress

I've got a simple homepage, that pulls content for 4 different categories. To do this, I'm writing 4 different WP_Query, and only the category name is changing (and as a result, the WP_Query name, ...
1
vote
0answers
71 views

How to get latest posts from each category in regular order

let's say I have a main query and it displays posts from Movies and Music categories. I want the query to show always 5 latest posts from Movies and 5 latest posts from Music category. When I create a ...
0
votes
1answer
68 views

Using WP meta query to show custom post types by a start and finish date

I have a custom post type called 'events', I have a page which displays events by each month. Each event has a start_date and finish_date custom field (using advanced custom fields plugin) which ...
0
votes
0answers
21 views

Search (Custom Form, Custom Search Result)

If I have a form: <form class="search" action="<?php echo site_url(); ?>/page-search?category=2" method="get"> <input type="text" required name="search" placeholder="Search"> ...
0
votes
1answer
42 views

Next / previous posts link doesn't show up with Posts 2 Posts

I am working on a Wordpress project where I use the Posts 2 Posts plugin to show posts from one post type to posts from another post type. This works great but for some reason my next_posts_link() ...
0
votes
0answers
22 views

How to exclude posts ordered by comment_count from subsequent wordpress loops using WP_Query?

My page has three separate loops on it. The first retrieves the most commented post. The query then resets for the second loop and retrieves the 3 most recent posts, then resets again to get the three ...
1
vote
2answers
43 views

Including all terms in wordpress tax_query

I'm a little bit confused, why I can't include all the terms in tax_query automatically? My code: 'tax_query' => array( array( 'taxonomy' => 'city', 'field' => 'slug', ...
0
votes
1answer
45 views

Show multiple categories in query using redux framework variable

Stuck on trying call an option variable using the Redux Framework - that is utilizing multi-category select - inside the query. Here's what I have as my query: $the_query = new WP_Query(array( ...
0
votes
1answer
18 views

How to display most recent posts that haven't already been displayed with WP_Query?

I have two content divs that each take up half of their containing div. My plan is to use WP_query to display the 6 most recent posts (3 in each.) It will go: Div 1 -> post 1, post 2, post 3 Div 2 ...
1
vote
1answer
61 views

Two different conditions with a single WP_Query

I need to get custom posts with next conditions: Custom post with meta 'key1' => 'public' Custom post with meta 'key1' => 'private' and 'author' => 'current_user_id' Code: $args = array( ...
0
votes
0answers
23 views

How to use tax_query other than by slug or id or solve custom taxonomy tags conflicts with pre-existing tags?

I just encountered a problem and realized that all tags must be globally unique. Here is what just happened to me: I created a taxonomy called writer and added each author and collaborator to the ...
0
votes
1answer
45 views

How to get specific string in explode array?

I have a shortcode where I'm trying to get a specific string from the $args array below. Query: <?php $args = array( //'post_type' => $posttype, 'post_type' => explode( ', ', $posttype ), ...
0
votes
0answers
8 views

*Add* items in a certain taxonomy to existing posts with pre_get_posts()

I've seen somewhat similar questions on here, but not exactly what I'm trying to do. Assuming I have this: function eg_homepage_pre_get_posts( $query ) { if ( ! is_admin() && ...
0
votes
1answer
33 views

How to avoid filling up an array each time I run a WP_query?

I am making a following user system and need some help for retrieving the users ids a user is following. At the moment I am using the following SQL query for retrieving the users ids a user is ...
-1
votes
1answer
47 views

posts_per_page - Repeats only first posts 'post__in' array

This question correlates with a previous question I was able to solve here: http://wordpress.stackexchange.com/a/137929/28389 I am using an array for 'post__in', and I am able to run this no problem. ...
0
votes
0answers
29 views

wordpress page filter problems

Hello I been working on post type filter so I can filter my content for taxonomies type but for what ever reason I can never get it to filter when I click filter public function product_filters( ...
0
votes
0answers
26 views

Custom URL in Wordpress with add_rewrite_rules and add_rewrite_endpoints

I have the following URL for a filter functionality that i try to build in wordpress: example.com/offers-type-all-inclusive-from-germany-transportation-airplane.html How can I make the arguments ...
0
votes
1answer
23 views

Executing query_posts after wp_insert_post

am working on a custom plugin. I'm programmatically adding a new post in the plugin use wp_insert_post. Works fine, the post gets added and I get the $post_id. However, if I immediately run ...
-1
votes
0answers
22 views

Accessing $_GET from within Wordpress Plugin [duplicate]

I have searched for the past two hours and I can't find a simple answer on how to access $_GET from a WordPress plugin. My plugin creates a ShortCode, and I would like to be able to pass the plugin ...
0
votes
0answers
15 views

Pre_get_posts query conditional

I try in "pre_get_posts" filter to alter the query so i can retrieve all posts that have been published by an author AND all posts with a certain meta value no matter the author.Is that possible or i ...
1
vote
2answers
71 views

Display Posts of a Category in Alphabetical Order (Custom Post Type)

I have a custom post type called "link" I have a custom taxonomy for this post type called "link-category" I have a template file for this taxonomy, "taxonomy-link-category.php" I need the template ...
0
votes
0answers
134 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
28 views

query single random post works localhost, not on live site

I was developing a site on localhost, and just transferred everything over to the live site. The queries are the exact same between the live and staging sites, But the query is not working on my live ...
0
votes
0answers
34 views

I cannot search users via user nicename

I use the following to build a users drop-down box: echo'<select name="user">'; echo'<option value="0">' . __('ALL', 'wpzoom') . '</option>'; foreach( $users as $user ){ echo ...
0
votes
0answers
18 views

Show taxonomy and custom post type in the same query

I am not sure how to raise the question, because I find all that goes in another way, I will try... I have three custom post types and these have their own taxonomies. The following is a simplified ...
0
votes
1answer
34 views

'Trying to get property of non-object' when using WP_Query with 'fields' => 'ids'

In an attempt to speed up my query, I'm using the following arguments: $args = array( 'post_type' => 'product', 'fields' => 'ids', ); $query = new WP_Query($args); While this does ...
0
votes
1answer
23 views

How to SQL query posts IDs by categories AND authors?

I am making a custom WP_Query and I need to come up with a SQL query that gets the posts IDs from X categories and Y authors. Then merge those IDs and put them in an array. I only need to figure out ...
0
votes
1answer
19 views

Select posts with any post_type from database?

I'm trying to select all rows from the database regardless of post type, however when suppressing post_type WP_Query only gets rows with post_type = "post" is there a way to suppress the post_type ...
0
votes
1answer
20 views

Two queries – one with checkbox ticked, one without – comparing meta_query

I am trying to do the following: Two queries 1. Get all people that have director 'yes' ticked 2. Get all people that don't have director 'yes' ticked I have the first query all set up and works ...
0
votes
1answer
25 views

Get post closest to today

as the title indicates I am trying to make a query for the post closest to today's date. I know this is a duplicate post but the ones I have found on the topic has not been able to solve my problem. ...
0
votes
2answers
19 views

Include both default and Custom Post Type in query modified inside pre_get_posts

I want to include custom post type in the author arhive page. I tried the method discussed in this post: Including post_type = 'wiki' in author archives add_action( 'pre_get_posts', ...
2
votes
1answer
59 views

Custom Post order for homepage

I would like to display a dropdown on the homepage which contains [most popular, most recent, trending] and when a user selects on of them the posts are page reloads and the posts are sorted in that ...
0
votes
0answers
11 views

return custom taxonomy terms in post object

How would I go about returning the custom taxonomies in the post object with WP Query or with get_posts for that matter. yes, I know I can loop over my query and use get_terms or a number of other ...
0
votes
1answer
28 views

Minimize database queries to user tables?

I'm trying to come up with a strategic way to collect large amounts of usermeta data (and output to the screen) while keeping database queries low. Some pages, like the home page, single pages, and ...
0
votes
1answer
45 views

Programmatically set 'meta_query' for filter

I am trying to set 'meta_query' programaticaly for a filter which is supposed to filter a custom post type depending on the existence of a metakey. I have tried several ways, which I have left in the ...
-1
votes
1answer
52 views

Wp query by 2 meta field - check if they exists / have value

I am looking for the shortest most resrouce affective (not mysql query) to count the amount of posts that have 2 meta keys <-- if they exists i found this simple way at the codex but it checks for ...
0
votes
0answers
100 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 ...