"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
0answers
15 views

Suggested posts from categories

I need a certain procedure to display suggested/similar posts for each post, but I've never done something like this, so I'd ask for some guidance: Take all the categories the current post belongs ...
0
votes
0answers
19 views

Querying Multiple Categories With Different Offsets

On my website I have a "Breaking News" section which shows the most recent 4 stories in the "Breaking News" Category. Under this I have a featured news section which displays 5 more stories from the ...
0
votes
0answers
21 views

Issue with permalinks for custom post type

I have a little issue here... When i'm using default permalinks, everything works great, but when I set up %postname% permalink in settings, my template with custom post type is not loaded. ...
1
vote
1answer
34 views

display posts with same taxonomy term

I'm trying to display 5 related posts in the loop, those related posts being posts that share the same taxonomy value. e.g. I have a custom taxonomy set up called venues thus each post has a venue ...
0
votes
1answer
16 views

'&' causes an error in my shortcode when I list the content of the page

I would like to list the specified pages with my shortcode, but the problems are with the '$' charachters. function get_page_func( $atts ) { extract(shortcode_atts( array( ...
0
votes
2answers
37 views

Get attached media only

I am using wp_query to get uploaded medias. Everything is working fine, but wp_query will return the medias with no post attached. This is not what I wanted. How can I exclude the unattached media ...
0
votes
0answers
36 views

New WP_Query loop in admin causes problems

I am working on a project where I have a custom post type 'companies' and on this edit page in the Wordpress admin I have some custom made meta boxes, for saving company information, opening hours, ...
2
votes
1answer
39 views

WordPress meta_query and order by custom field

I have a Custom Post Type called "Films", with a Repeater field called "Showings", which have a field "start_datetime" of type DateTime... I want to perform a query to get all those Films with a ...
0
votes
1answer
38 views

Not duplicating $post->ID leaves empty space.

My home page has a section at the top that displays a featured post from a time period if it has been set, otherwise it displays the most commented post of a time period, or it just displays the most ...
0
votes
1answer
41 views

Conditionals in WP_Query

What I'm trying to do is this: If in the last 7 days someone has added a post in the category 'featured' display it in the loop. Otherwise, display the most commented post from the last seven days. ...
2
votes
1answer
85 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
47 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
61 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
129 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
42 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
20 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
99 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
53 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
35 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
45 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
28 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
45 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
73 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
80 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
43 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
23 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
49 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
48 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
62 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
24 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
47 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
35 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
55 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
32 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
29 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 ...
0
votes
0answers
16 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
80 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
150 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
31 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
35 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
24 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 ...