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

How to reduce the number of queries?

I have meta key "Due" for posts....if a post has expired (past the current date or not equal to it) then it will not be displayed in the count. This is my code, which works perfectly. My only problem ...
1
vote
1answer
100 views

Order posts by 2 custom fields and if one custom field is zero orderby another custom field

I have a really tricky function to implement and couldn't find a way by searching Please see details below I have a custom post type called "accommodation", and for this post type, there are 2 ...
1
vote
1answer
982 views

Auto Populate Custom Field with Complex Value That Increase by One?

Can somebody help me to sort this? I am using WP 3.5.2 and I have "Orders" post type where purchase_order custom field is located. This is the sample of purchase order record: POCOS20130051 PO - ...
1
vote
1answer
157 views

Gallery shortcode numerical sorting

When I try to sort a Gallery created through the [gallery] shortcode by numerical titles I get them sorted in alphabetical order. That means that they are sorted like so: 1, 3, 34, 4, 56, 6, etc. ...
1
vote
1answer
85 views

Query Posts With Over 1000 Views

The code below is from this link. It basically creates a hit counter, but I'm probably gonna have to do this by IP. How do I make a WP_Query, where only posts up to 1000 views can be seen on the ...
1
vote
1answer
70 views

How to combine custom fields to make one order-able value

I have three different custom fields, for day (01-07) hour (01-12) and minute (00-59) and I really need to combine them into one custom value so I can actually order them using wp_query. I cant ...
1
vote
1answer
572 views

Too many posts cause slow load when paginating

I have about 10k posts and I made a page that lists all posts but it is paginated every 54posts. It gives 131 queries in 6.730 seconds which is pretty slow to load. Is there a way to make it load ...
1
vote
1answer
81 views

change recent posts based on category

I am writing a code to display the recent posts of different categories. On clicking category 1, I want to display the recent posts from cat1 and on clicking cat 2 the recent posts from cat2 and so on....
1
vote
1answer
78 views

How to list posts with disabled/closed comments, with pagination?

i'm interested how to display all posts (from all categories) that have closed/disabled comments? I have tried using the comments_open() function inside the loop, that works, i don't know how to ...
1
vote
1answer
192 views

Query Page Content From Theme Options?

I'm trying to create a slider where you choose what pages are shown in the slider, using a theme options panel based on the https://github.com/vauvarin/options-framework-theme That lists the pages in ...
1
vote
1answer
169 views

posts_per_page option limits the number of Gallery items

I have noticed that if I have a query where posts_per_page are set to 4, any (image) gallery that belongs to one of those posts will too have only 4 items (although when I create the gallery from Add ...
1
vote
1answer
559 views

WP_Query not retrieving by random order under parent

I currently have TWO subpages under parent page ID 43. Client testimonials.. Anyway. I have the random order thing in the query $args but the order never changes. What could I be missing? ...
0
votes
1answer
21 views

I want to get title name of post, but i didn't get by this code. Any suggestion?

add_shortcode('sort_featured_restaurant','sort_featured'); function sort_featured(){ $the_query = new WP_Query( $args ); // The Loop if ( $the_query->have_posts() ) { echo '<ul>'; ...
0
votes
1answer
19 views

Query events post type after current date and timezone

So I am making changes to a clients website and currently they have an events post type with some custom fields that allow them to set an events end date/time and the events timezone. The custom ...
0
votes
1answer
23 views

WP_Query Custom Post Type if Category ID Equals

I've setup a custom post type "slides" and I've created two categories for the slides custom post type: "slides-testimonial" (id = 7) and "slides-regular" (id=8). I would like to run a single loop, ...
0
votes
1answer
19 views

Object of class WP_Query could not be converted to int inside shortcode

I have the following code which is used to display download posts by the custom taxonomy. I am receiving the error Object of class WP_Query could not be converted to int When I have Query ...
0
votes
1answer
28 views

Is it possible to retrieve posts depending on meta_key LIKE condition?

I'm currently facing a little problem. I'm using ACF plugin which generate complex meta_key names when creating hierarchical fields. I found in my database meta_key named modules_1_content_0_module. ...
0
votes
1answer
41 views

How to fix pagination for custom loops on front-page.php

A search on this topic on this site throws up a lot of results claiming to have resolved this issue, but I am having a contrary experience after implementing these guidelines as outlined here: How ...
0
votes
1answer
26 views

Dividing the loop to style post differently

I'm using a plugin that displays post and shows them in a certain area on my site, such as the sidebar or anywhere i put the <?php;?> code, but only if the author that is writing the post clicks ...
0
votes
1answer
33 views

Creating Ordered Query using Meta_key

I've hit a massive roadblock that I've been stuck on for days now, hope someone can help with this. The problem: I have a custom field called order_value with the values road, air and bus. I am ...
0
votes
1answer
67 views

How to provide meta_key array to wp_query?

I'm trying to build a wp_query, so far I've managed to get desired result using following query. $args = array( 'meta_query' => array( 'relation' => 'OR', array( //check if ...
0
votes
1answer
23 views

WP_Query returns empty if meta_query has more than 7 values

I have a custom loop to display a custom post type 'properties' . The idea is to search properties based on different search parameters selected by users. Now the weird problem I am facing is that if ...
0
votes
1answer
34 views

Show one item per category of a custom post type

I'm having a custom type called portfolio with different categories. I want to display all my categories except one. I only want to show one item per category on my page. I'm been busting my butt on ...
0
votes
1answer
24 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
20 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
1answer
59 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
1answer
37 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 ...
0
votes
1answer
38 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
1answer
13 views

Retrieve custom post by a query on one of its custom fields

I've been using custom posts on my website, among them there are : "session" and "lecture". The custom post "lecture" has many custom fields such "title", "duration"... The custom post "session" ...
0
votes
1answer
16 views

Change posts archive ordering

I need to change the order of my default posts archives so I have added this to my functions.php but it doesn't affect anything... I've looked at various examples and from what I can see it should ...
0
votes
1answer
63 views

meta_query not working properly

I'm trying to run a query that only displays items that meet a condition in an Advanced Custom Fields select box, but I'm getting nothing. Here's my query. Any help would be appreciated: <?php $...
0
votes
1answer
27 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( 'post_type=...
0
votes
1answer
38 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 ...
0
votes
1answer
67 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
136 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
1answer
43 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
1answer
65 views

Order wp_query by calculated field

Hi I'm working on a store locator. I have a custom post "clinics" where I save clinic details (address,.., lat, lng). Each time I publish a new clinic I save post_id, lat and lng also in a custom ...
0
votes
1answer
49 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 ...
0
votes
1answer
59 views

Get query result according to merged array

1st query selecting the records that are found $old_args = array( 'post_type' => 'product', 'meta_query' => array( 'relation' => 'AND', array( 'key' => ...
0
votes
1answer
168 views

Get a list of ACF Repeater-Fields as array

I run a Site for a concert & music club. Events are set within a custom post type called "events". In this i set the date, the name of the event and all other infos about that event. In this ...
0
votes
1answer
61 views

Improving WP_Query for performance when random posts are ordered

I have made a new query after I've asked a question about my query_posts code... you guys didn't find that great, so I decided to change that. I made this: $page = (get_query_var('paged')) ? ...
0
votes
1answer
25 views

Include post_status check within $wpdb query

I've got a function that returns a count from the database for publish posts that match the product ID to the post meta ID (both are the product type). I've realized this query returns unpublished ...
0
votes
1answer
49 views

Display Year and Month from custom field + Age Calculator

I have a custom field "DOB" on my custom post type which is in [Ymd] format. I want to compare that date of birth to current time and want to show "You are # years # months." I am able to calculate ...
0
votes
1answer
34 views

How to order by datediff in WP loop?

I have a custom post type for events with a custom field named event_start_date, and I want to sort the archive loop according to the nearest event_start_date. In other words, the event with the ...
0
votes
1answer
27 views

Query with two posttypes and two different meta_keys

I need to query two custom post types, like this: 'post_type' => array ('single_events', 'group_of_events'), and i need to select certain posts in a certain order, to do this i wrote a meta ...
0
votes
1answer
100 views

query_vars empty when using custom url with custom rewrite rule

I'm trying to pass custom url parameters to pretty urls using add_rewrite_tag('%product%', '([0-9/]+)'); add_rewrite_rule('^sign-up/product/([0-9/]+)?$','index.php?pagename=sign-up&product=$...
0
votes
1answer
61 views

Moving the array pointer inside a WP_Query while loop

How can I move the pointer ahead a place, or at least offset it, as I'm trying to pull two posts during each loop of the while loop? I've indicated where in the loop I would like to move the pointer: ...
0
votes
1answer
108 views

wpdb get_results() returns only 2 rows

I am trying to create custom admin widget to present how many users has registered within last days. I have created function as below: function mdbootstrap_add_dashboard_recent_users(){ global $wpdb;...
0
votes
1answer
33 views

Keeping the previous get value and add another value when submitted

I'm a super noob, so I'll try my best to explain. I have a blog page that I wanted filtered by category and I want the user to able to click on multiple categories and it will filter to show those ...
0
votes
1answer
32 views

Duplicates When using Nested WP_Query

I think I'm missing something really simple but I'm at my wits end and hoping to be pointed in the right direction. A little background. I'm working on a site for a creative agency. I'm using ...