Tagged Questions

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

i want order by meta value pro first then meta value free in my search function of theme

my meta key is geo_listing_type and this key have 2 meta_value pro and free i want it order by pro first then free function gc_multi_search( $sfrom, $location, $limit = null ) { global $wpdb; if ( ...
0
votes
2answers
9 views

getting content from main domain to sub-domain using category and WP_Query

I have a main website with 2 sub domains. www.example.com www.space.example.com www.products.example.com I want to publish articles on my main website using categories to sort them. for example, ...
0
votes
0answers
26 views

More efficient query to display posts in same sub-category?

[EDIT: See my comment below, I may have been fooled by Chrome caching an earlier version of this code. It now seems to run quite quickly. Leaving the question up in case anyone sees a better way but ...
0
votes
1answer
21 views

How to query posts with current or future date only

I want to only get posts with current or future dates, to show upcoming events. Current arguments: $args = array( 'post_type' => 'event', 'meta_key' => 'event_start_date', ...
0
votes
0answers
12 views

Date fromate using wp_query for previous post [on hold]

I tried this code <?php $prev_post = get_previous_post(); if (!empty( $prev_post )): ?> <a href="<?php echo get_permalink( $prev_post->ID ); ?>"><?php echo ...
0
votes
0answers
21 views

Post type archive pages with custom query

Apologies if this is something trivial, but I can't seem to get it right and I can't quite find the correct way to tackle this from previous questions. I am building my own theme. I have the normal ...
0
votes
1answer
40 views

WP_Query freezing

So I have stumbled across a number of similar questions on SO, but my understanding of wp_query and advanced PHP is limited. I think I am getting lost in the PHP objects / arrays and the use of ...
0
votes
0answers
16 views

Ordering a custom meta query

I have a events custom post type. Each event has to meta fields: eventstart and eventend. These are both YYYY-MM-DD style dates. I am trying to get a list of my events that have a start date OR end ...
0
votes
0answers
10 views

Meta query with compare by more than 2 fields

i have 5 sets of meta boxes in some custom postype. So.. i know how to compare two meta box values... Example: 'meta_query' => array( 'relation' => 'AND', array( 'key' ...
0
votes
0answers
18 views

Bare-bones WP Query location search

I need to develop a Wordpress query that filters a custom post by zip radius. I'll be using ACF Google fields to store the location of each custom post type. Here's where I am thus far. Wordpress ...
0
votes
1answer
20 views

Query by key or author

So right now my query looks like this: $allsearch = &new WP_Query("s=$s&showposts=-1"); I understand what this query does and it works, but not I want to add the ability to query posts by ...
0
votes
0answers
7 views

Running posts thumbnails in flexslider

This is what i'm trying to achieve: Front page with 10 posts, with three first posts shown in a slider (flexslider) and the rest shown as regular excerpts underneath it. Ive managed to do it, this is ...
0
votes
1answer
23 views

Loop doesn't exclude the specified category in home page

Oh, hello! I want to show the three most recent blog posts in the home page, excluding the "featured" category, which has the ID 8. In order to see the ID for that category, I went to Posts > Category ...
0
votes
1answer
20 views

How do I display posts with specific value in a custom field into my loop?

I'm trying to display posts that contains a specific value from my custom field. For example, I created a custom field that asks for the year, let's say I would like to display only posts with the ...
0
votes
1answer
41 views

Query Posts, order by meta value

I've read a lot, tried a lot more, but can't get what I want: I have custom post types, which I want to order in DESC, orderby its meta value: The complete query with its arguments: ...
0
votes
0answers
22 views

Getting duplicate results from query

I'm confused as to why I'm getting duplicate posts showing up in my code for two related blog posts (by current category). The secondary posts are showing up outside the intended div, and not even ...
0
votes
1answer
23 views

post_per_page ignored in WP_Query

I have a custom post type named 'album' and I added two custom fields 'release_date' and 'release_date_us' with the ACF plugin. I'm trying to display the latest albums based in a widget area. The ...
0
votes
0answers
5 views

Filter get_projects_category();

Is it possible to amend the <?php get_projects_category(); ?> to only get projects from specific categories? The previous code is populating a menu with category links, and I only want certain ...
0
votes
1answer
20 views

Get posts with multiple categories

How to get just the common posts of 2 different categories? consider this category tree: posttype -news -arrangement --course --competetion --other region -region1 -region2 -region3 Now I want to ...
0
votes
1answer
20 views

category__in not working on custom post type

Can't get my WP_Query loop to work, cannot figure out why category__in won't work. Just want to pull certain categories FROM my custom post type $args = array( 'post_type' => 'bbt', ...
0
votes
2answers
27 views

Change query from cat id to slug or name?

I'm using the following query to fetch posts in a category (10). I would like to change this code to use the category slug or name instead of the id number as this often changes when I move sites ...
1
vote
1answer
33 views

Query wp_usermeta alongside wp_users

I want to use the WordPress query functions and no external plugins for the task. Here is what I have so far: add_filter('user_search_columns', 'user_search_columns_bd' , 10, 3); function ...
0
votes
0answers
33 views

How can get Custom Posts Sort by Hour

I need to show posts from 00:00:00 AM to 00:00:00 PM, and orderby day too. How can i do that? Look the following code: $programasQuery = new WP_Query(array( "post_type" ...
0
votes
2answers
37 views

Show single posts date, in a page of posts

In a page of posts, how do I show their date, instead of the page date? I have no php knowledge. Let's say I want to show the single posts date here, instead to the single posts title. <?php ...
0
votes
1answer
18 views

Page displaying 1st post from a range of custom tax?

Is it possible to have a page display the 1st post from each category from a custom taxonomy? e.g custom tax called gallery-section, within that it has a range of categories, i.e Gallery 1, Gallery 2 ...
0
votes
0answers
12 views

One Custom Post Type Not Displaying in Second CPT

I have a custom post type (Books) that is connected with a second custom post type (People). The Books CPT has an additional author meta box that if checked, it should appear on the additional People ...
0
votes
2answers
34 views

Get post ids from WP_Query?

Is there a way I can retrieve an array of post ids queried from the following: $latest = new WP_Query( array ( 'orderby' => 'rand', 'posts_per_page' => 3 )); if ( ...
3
votes
1answer
64 views

Order by meta_value_num DESC and meta_value ASC on WP 4.0

I have created a custom post type that I want to order by custom-field-1, which is boolean so its value is either 1 or 0, in DESC order (1 to 0) custom-field-2, which contains text and is supposed ...
0
votes
0answers
18 views

$wp->query_vars redirection giving me error

I am using plugin which is working based on short code.And I want to redirect to one template for single location. And I have given href like this to the plugin- ?wpsl-id= So basically what I have ...
0
votes
0answers
29 views

Orderby Meta Value and Query from Meta Query

The following query is returning blank with no errors and I'm not sure why. Query Arguments: $args = array( 'post_type' => 'games' , 'posts_per_page'=> -1, 'meta_query' ...
0
votes
2answers
48 views

get_posts query matches too many results

I have a query inside a function that is returning matches that i don't want, for example when the $id=116 it is also returning results where the meta_key 'funds_id' is 11687. public function ...
-1
votes
0answers
18 views

how to simplify multiple wp_query with different meta values

Their are 6 total queries I need to use, below is list of 2 of them. Is it possible to simplify it? as you can see the key is the different values of meta_value, there are 1-6. <?php $args1 = ...
0
votes
0answers
25 views

Can I use pretty URLs for paramaters without query_vars?

I have a plugin that retrieves data from custom non-WordPress tables. I'd like to be able to add pretty URLs to retrieve the data, but as far as I can tell, if I use the add_rewrite_rule and ...
0
votes
0answers
21 views

query wordpress page template

I'm making a one page template and have a menu set up to control the pages that are being displayed. I want to query the pages from the menu, however include the template with all the page data (php ...
0
votes
0answers
10 views

Post returns wrong result when adding Arabic parameter to WP_Query

I have a WP_Query which works perfectly when I use an English parameter like this: $the_query = new WP_Query( 'tag=english param'); but when I add this: $the_query = new WP_Query( 'tag=arabic ...
0
votes
2answers
21 views

Efficient way to update multiple post meta

I have managed to update post meta using update_post_meta(). However, the more posts I have, the more time it takes. I would like to minimize the time it takes to process say about 400 posts (although ...
0
votes
2answers
34 views

Combine privileged users array with my current query

I have a custom page template with the following query. Isotope filers my categories and all this works fine. I want now to make this page only viewable by a few specific, currently logged in ...
0
votes
2answers
26 views

How to get post id of static front page?

I'm trying to use the front page as a default of sorts for featured images (if no featured image is set, I want to use the front page's, for example) But I'm having trouble finding out how to get the ...
0
votes
2answers
36 views

Pagination not working in secondary query

I'm trying to fix a theme which has the following setup: on each page the user can select to list posts instead of the page content. The problem is that the pagination doesn't work on this page even ...
-1
votes
0answers
22 views

Cannot access to wp_query for custom query

On a custom page template, I run a custom query to get posts, here it is: $wp_query = new WP_Query( $args ); if ( $wp_query -> have_posts() ) : while ( $wp_query -> have_posts() ) : ...
0
votes
0answers
31 views

Show sticky post before other WP_Query

$recent_posts = new WP_Query( array('posts_per_page' => $blog_num_posts, 'paged' => $paged, 'post_type' => 'post', 'post_status' ...
0
votes
0answers
24 views

Sort order not working properly with meta_query

I have a template that pulls a custom post type for properties and sorts them by state. The script works properly until you add in a meta_query for the agent. It pulls the correct properties, but it ...
0
votes
1answer
21 views

ajax wp_query conditional tags not working

I'm trying to ajax wp_query, I got success getting posts for home page with the following code. Then I added conditional tags to modify the query for the other pages like Category page the problem ...
0
votes
1answer
23 views

Sort by custom field that is an array?

is it possible to sort posts inside a query based on post value that is in an array - but using the last element of the array? The code looks something like: <?php $mostsharedposts= new ...
0
votes
2answers
40 views

Custom taxonomy wp_query woes.

Here's a brief outline of the set-up: "The Art" CPT is where all the art and art descriptions are uploaded. In this CPT you can choose the category (custom taxonomy) of the art--painting, jewelry, ...
4
votes
1answer
153 views

How to Compare Two Meta Fields

Consider two meta fields balance and monthly_price. How you would get all posts that has balance < monthly_price Thinking of creating meta query but our both fields are arbitrary or do not have ...
1
vote
1answer
31 views

Date query not inclusive despite parameter being true

I've set up a small test query to get some posts from October 1 to October 10. I published a post today ( October 10 ) and with the date query parameter of include set to true, I would have expected ...
0
votes
0answers
11 views

Do not count menu items in posts_per_page

Custom type posts are added to query for category page: function test__pre_get_posts( $query ) { if( !is_home() ) { if( is_main_query() || is_category() ) { $query->set( 'post_type', ...
0
votes
0answers
29 views

how to show a tooltip include of thumbnail and excerpt when hovering a post link in other post?

Is there any way to call thumbnail and excerpt for link of post in another wordpress post? For example when i hover a post link in other posts, it shows a tooltip include of thumbnail, excerpt. Like ...
0
votes
0answers
26 views

WP Query to order posts by multiple meta fields

This question might have an answer already in the forums, however I still wanted to ask it as this is a different more complicated version of the problem. The story: We have 2 meta fields for ...