"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
vote
1answer
40 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 ...
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) { if(!...
0
votes
2answers
4k 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
3answers
22k 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 ...
4
votes
1answer
40 views

Executing Queries in tag.php

I'm probably being dense, but I can't seem to figure out what the issue here is. The site I'm developing uses a custom loop, with a query that excludes any posts ticked as archived. The reason I ...
0
votes
0answers
22 views

wp query doesn't return html tags

In file I have the following (only part is showed below): <?php $args = array( 'name' => 'contact-us', 'post_type' => 'page' ); $q = new WP_Query($args); ...
0
votes
0answers
24 views

Why a WP_Query instance using 'tag' doesn't work?

everybody. I'm developing a small plugin and I need to fetch some posts with a very simple query: $args = array( 'tag' => $tag ); $fc_query = new WP_Query( $args ); The point here is ...
0
votes
1answer
26 views

Can't get data from audio media

I am trying the get the data of an audio, I've uploaded to a Wordpress site I'm working on (Not my own). I'm quite new to WordPress, but as far as I know, media files such as images and audio is ...
0
votes
1answer
18 views

orderby in WP_QUERY - Use the order from the Dashboard

I'm using the Anything Order Plugin to order custom post types in my dashboard. For a wp_query, I'd like the output to order the posts in the same order as I have them in the dashboard. What would ...
2
votes
0answers
21 views

Select menu should display categories and the item's depth

I have a select menu of a custom post type in the header.php: <?php $selectloop = new WP_Query( array( 'post_type' => 'products', 'posts_per_page' => -1 ) ); echo '<form>&...
0
votes
1answer
25 views

Rewrite rule pagination on different url levels

I have a custom post type called shop with product posts in it. This post type is connected to a taxonomy shop-category, to specify a product section inside the shop. Each product has a item_width ...
6
votes
3answers
68 views

Random sort within an already sorted query

I have a working query which returns a set of custom posts which are ordered by their package ID (ASC). For a query with 9 results this may return for example: 4 posts (Post ID's 1,2,3,4) with ...
0
votes
0answers
58 views

Search result by taxonomy name

Currently my search filters by title and I'm trying to filtered by taxonomy tags. How do you I do that. Here is my code: $query = " SELECT * FROM $wpdb->posts WHERE $wpdb->posts.post_status = '...
0
votes
5answers
608 views

Why always one post missing

In my custom query, every time I query for posts from a particular category using WP_Query() and the category has 10 posts for example, I seem to be missing a post. So querying for 10 posts only ...
0
votes
0answers
46 views

Add post order to function

How to add post order to this function? I would like to display most recent post from newest to oldest: <?php //Establish first post check variable $first_post = true; query_posts('category_name=...
1
vote
2answers
34 views

how to merge a WPQuery array with a PHP array and use the Loop to Output the result

I have a mostly normal WPQuery (getting 3 post types) for use on a Blog page. This works great. Client wants Instagram images to be included and ordered by date. I have all the instagram code setup ...
1
vote
1answer
30 views

Search pages that are a child of the current page

I'm developing my own Wordpress theme and I was wondering if it is possible to modify the search query in a way that it only return results that are child pages of the actual page. The reason I want ...
0
votes
1answer
21 views

Query pulling all taxonomies, not one I am specifying

I am trying to grab one random post from a custom Post Type I have that has a taxonomy that I give to it. For some reason it is pulling any post, no matter the category. Here is my Post Type if (!...
0
votes
0answers
13 views

using session var to filter author media gallery

I got a problem to solve and would like to know if I'm looking the right way to solve this. I have a site where multiple authors can upload images and they all have a profile page (author.php) where ...
0
votes
3answers
71 views

Can't figure out query logic

Help me figure out how to structure this meta_query within my post query! There are two taxonomies attached to my post type ('audition_type', and 'union_requirement'). On a page of my site the user ...
0
votes
0answers
29 views

Orderby one meta key, remove posts with another

I am trying to order custom posts with a custom taxonomy with a meta key value. I am also trying to remove posts from that loop if they are past the date set by another meta key. Here's my code: ...
0
votes
1answer
5k views

WP_Query by Category Name

Hi I am using some code to display posts in a slider on a page, and at the top I have some code to filter it using WP_Query. Here it is, not sure what is wrong: <?php /** * Featured Content 2 * ...
1
vote
1answer
65 views

new WP_Query to get max price meta value not working

So, I'm trying to get the maximum price of all 'properties' (custom post type). $max_price_query = new WP_query(array( 'posts_per_page' => -1, 'post_status' => 'publish', 'post_type'...
0
votes
0answers
44 views

Query breaking with 'posts_per_page' => -1

I'm trying to return all posts for a category associated with a custom post type. I have the following query: $cat_name = single_cat_title('', FALSE); $termObj = get_term_by('name', $cat_name, '...
0
votes
0answers
15 views

Tax Query not generating correct query [duplicate]

I have the following query setup to pull videos from a custom post type by category: $cat_name = single_cat_title('', FALSE); $videos = new WP_Query(array( 'post_type' => 'video', '...
1
vote
1answer
17 views

Attachment changing page's permalink - $post not resetting?

I have a function that I use to populate from checkboxes on a page's edit view (post.php?action=edit). I call this function when I render a metabox on the editor page. function ...
6
votes
3answers
4k views

Can wp_query return posts meta in a single request?

I would like to create a wp_query that would return posts meta inside the posts array. $args = array ( 'post_type' => 'page', 'meta_key' => 'someMetaKeyName', ); // The Query $query = ...
0
votes
0answers
18 views

WordPress loop by three meta values with random order

We have three custom fields with names plan_name1,plan_name2 and plan_name3. Need to check if these meta keys has values (1,2,3) OR (2,3,1) OR (1,3,2) OR (2,1,3) OR (3,2,1) OR (3,1,2) We mean ...
0
votes
0answers
33 views

Is it possible to search for a string in posts OR postmeta?

If I have a text string $search_string and construct a query like this: $args = array( 's' => $searchstring; 'meta_query' = array( array( 'key' => 'my_key', 'value' =&...
0
votes
0answers
19 views

WP_Query only displaying one post with custom_taxononomy

I’m attempting to show all posts attributed to the taxonomy item "people", though my query is only displaying one post with the following code. Any suggestions much appreciated! <?php // query $...
-1
votes
1answer
29 views

Best Way to Inventory the Media Library of a 200+ Multisite Installation?

I have a multisite installation of WordPress with 200+ sites. I recently was tasked to do an inventory of each site's media library and was wondering if this could be accomplished programmatically ...
1
vote
0answers
39 views

order by multiple meta keys in pre_get_posts

I want multiple orderby meta_query eg: orderby(‘_property_price’ => ‘DESC’,’_property_featured’ => ‘DESC’) This is what I am doing $query->set('meta_key',array('_property_price','...
1
vote
0answers
69 views

Display Featured Image On Hover in Seperate Div [closed]

Hi I'm trying to accomplish showing my featured thumbnail on hover. Here is a photo example. The photo on the left is the featured image for the first post on the right. I want first post ...
0
votes
2answers
456 views

Trying to list out child pages with WP_Query

I'm trying to list out all the child pages of a custom page I've made. In my custom page, I'm doing this to list out the pages: <?php get_header(); ?> <?php $subpages = new WP_Query( ...
0
votes
1answer
27 views

wp query error while paging the posts

i am new to wordpress and i am learning paging the posts but the code below isnt working and i cant find whats wrong. please help. the code: <?php $temp = $wp_query; $wp_query= null; $paged = ( ...
1
vote
1answer
51 views

Query with custom taxonomy not working

I have custom post type 'mix'. And custom taxonomy 'meal'. And categories in custom taxonomy (one of that is with slug: breakfast) I have problems with making query. My code is : $args ...
0
votes
1answer
1k views

WP_Query orderby random do not repeat infinite scroll - one loop

I have found a lot of documentation on solving this issue with multiple loops, I'm finding it hard to see a solution for one custom loop. Problem: I'm using infinite scroll to load in the next page ...
0
votes
1answer
65 views

Custom post WP_Query infinite loop error

I am trying to build wp_query loop with custom post type and it seems I get the infinite loop as the result. Here is my code that I am using: $apartargs = array ( 'post_type' => 'apartmani', ...
0
votes
0answers
18 views

meta_query in $args ignored when called from theme

I have the below function in my plugin in the MyManager class. public static function test() { $numRowLimit = 6; $arrArgs = array( 'posts_per_page' => $numRowLimit, '...
0
votes
2answers
116 views

How to overwrite orderby with add_query_var

So I would like to have an archive that displays its posts in a random order. <?php $query = new WP_Query($query_string."&orderby=rand"); ?> But also then if the user chooses they ...
0
votes
2answers
38 views

Problem with infinite scroll on multisite with custom query

I have a WordPress Multisite that uses a special query that combines all the posts on the network and uses the main site to display all posts in the network. Anyway, I would like to have my site use ...
0
votes
1answer
39 views

Show more than one post on the main page excluding certain category

I'm currently running WordPress 4.5 with a WooTheme called The Morning After. I decided to change a few things here and there, but encountered some issues regarding the posts_per_page argument used in ...
1
vote
1answer
113 views

WP_Query times out

I have a form with 20 inputs that runs WP_Query and recieves results via ajax. For some reason: query gets considerably slower when 5+ inputs are filled It takes like 10 - 15s with 7 input values ...
0
votes
2answers
44 views

WP Query and date format

I've been using a CPT named "session" that has some date fields. Those date fields are stored via the CMB2 plugin with something like this : $cmb->add_field( array( 'name' => __('Begin :', '...
4
votes
2answers
4k views

Meta query with boolean true/false value

I'm trying to show all rental properties, first by all properties that have not been rented, and then by all properties that are currently rented. There is a custom post type 'rent' with custom post ...
0
votes
1answer
52 views

WP_Query: How do I sort on meta value and use LEFT JOIN?

I use Wordpress 4.5 and I am trying to modify a query to use LEFT JOIN instead of INNER JOIN. But I cannot get 'relation' => 'OR' to work. See the query below. I have read a number of other posts ...
0
votes
0answers
70 views

WP_Query (list) posts according to author's custom field

I'm trying to work out or even find a way to list all the posts according to a custom field of the authors. I'm using WP User Frontend Pro and the plugin allows me to create custom fields for the user/...
0
votes
2answers
74 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
1answer
28 views

query post by author gender

I'm using utimate member plugin on my website. for each member (author), I have a field to store the member gender. (Homme / Femme). the data is stored in my database, inside wp_usermeta. meta key ...
1
vote
1answer
22 views

Wordpress add_rewrite_rule() cannot visit lower url levels

I have a post type called "shop" and added query variables and a rewrite rule. // Adds query vars for shop post type function gtp_add_shop_query_vars( $vars ) { $vars[] = 'shop-category'; $...