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

Paginate User Query

I am trying to write a simple shortcode function that will return a list of users based on a given meta value. It functions fine, but I am trying to paginate the list. Here is my code: function ...
0
votes
1answer
42 views

How do I add an item to the WP admin menu?

I want to add an item to my WordPress admin menu - "News" - it's to contain a list of articles written about my company. Each article will consist of the following metadata: Headline Date Link to ...
0
votes
0answers
32 views

Order posts by custom field

I have 2 types of posts - event and news. For event category, I have a custom field - event_date while news does not have that field. I want to order the posts according to the event_date. I want to ...
0
votes
0answers
20 views

Sorting posts with a custom algorithm

What is the best way to be able to sort posts in WP_Query by an algorithm, such as: (total votes) * (1 / hours since submission)
0
votes
1answer
18 views

Issue with WP_Query (need a array of selected ID's)

Today I have <?php $loop = new WP_Query( array( 'post_type' => 'inspirations', 'posts_per_page' => 50 ) ); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> ...
0
votes
0answers
19 views

Use meta to match date in WP_Query

I have some posts with a custom filed named "event_end_date". I am using Advanced custom fields for that. How can I get the posts which have end_date older than today? I was trying with this, but ...
0
votes
1answer
54 views

Get post thumbnail in WP_Query

I wrote an Ajax suggest plugin and I want to get the post thumbnail, but don't know how. This is my plugin code: $s = trim( stripslashes( $_GET['q'] ) ); $query_args = apply_filters( ...
0
votes
1answer
32 views

query multiple taxonomies

I have a function set up to show 'Similar Products', i.e. showing products that share the same products-category taxonomy term. This works great but I want to narrow the function even further and make ...
9
votes
1answer
107 views

Should we trust the post globals

@toscho left a comment to this answer which had me thinking again. How much trust should he have in the global scope, specially regarding the post globals like $post. So what? The global variable ...
0
votes
1answer
77 views

SELECT * FROM $wpdb->posts WHERE ID > 160

I would like to retrieve all posts and relative tag with ID greater than 160. I tried: '$args=array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 5, 'orderby'=> ...
0
votes
2answers
283 views

Loop through categories and create tab for each

I'm trying to create a page that holds all categories of my custom post type as tabs, with a tab content. I am able to display all the category names as tabs, but i need to run a query in each tab ...
0
votes
0answers
16 views

Help : how to Display only 3 random post from the most recent 100 in 120 days

that's my code : $args=array('post__not_in' => array($post->ID),'posts_per_page' => $related_no, 'orderby' => 'meta_value_num' , 'meta_key' => 'tie_views', 'post_status' => ...
0
votes
1answer
38 views

Get posts with no tags?

I have over 1000 posts with no tags. Basically I am trying to get posts with no tags to show in frontend so that users can add tags from frontend. I am using this approach in loop so as to show posts ...
0
votes
0answers
9 views

AJAX Returns an error when deleting post

I would like to delete the post using wp_delete_post via AJAX however while wp_trash_post works beautifully, the wp_delete_post returns an AJAX error. I used WP_Query to delete the post that is in ...
0
votes
0answers
15 views

Modified query_string has stopped working in WP4

The code blow was used to load a filtered taxonomy archive and worked fine up until the release of WordPress 4.0. Since upgrading to 4.0, it's not returning any results. Any ideas what might have ...
0
votes
0answers
47 views

query and paginate multiple post types

I'm looking to query multiple post types and paginate them so the results are across multiple pages. The markup I have is as follows: <?php query_posts( array( 'posts_per_page' => 100, ...
0
votes
1answer
74 views

tax_query showing no results

I'm creating a music database site with two custom post types: tracks and albums. I've linked the tracks to their respective albums with a custom taxonomy for the album's slug. On each album page, I'm ...
3
votes
1answer
502 views

Excluding a custom taxonomy term breaks wp_get_post_terms

I'm trying to exclude one custom taxonomy from an archive page, and then show the terms of the returned posts. When I run WP_Query to exclude the custom term, it returns the posts correctly, but no ...
0
votes
1answer
36 views

Multiple meta query from array

I need to do multiple meta query from my array. I have something like this: $search_term[] = array( 'key' => '_cmb_listing_status', 'value' => 'Active', 'compare' => '=' ); foreach ( ...
0
votes
1answer
25 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
1answer
60 views

Avoid duplicate while merging two query post

I have merged two query post, but when I fetch their results, it shows duplicates. Here is the code $arg = array('post_type' => 'story','post_status' => 'publish', 'orderby' => 'date', ...
0
votes
0answers
48 views

Meta Compare (EXISTS) does not work

I want to include the posts that have a certain meta_key and exclude those that does not have that meta_key. NOT EXISTS works but EXISTS fails in the code below. function include_meta_key( $wp_query ...
0
votes
1answer
535 views

WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)

I'm trying to write a new "related posts" widget (for the single post view) for my custom post type, filtering by custom taxonomy terms that the related posts should have in common with the current ...
0
votes
1answer
38 views

Order WP_Query results in order other than ASC or DESC

I have pages with a custom field "language" which can be, say, "EN", DE" or "FR". On a category page I want to output them in a specific order, say, first EN pages, then FR pages, then DE pages. It ...
0
votes
1answer
26 views

Advanced Post Display/Pagination/Ordering

I am working on a project that requires some advanced ordering of posts and advanced pagination. Basically, we have posts in a category, lets call this category 'mycategory'. We then have post ...
1
vote
1answer
5k views

Multiple WP_Query loops with Pagination

There are a few other questions about this (and WP_Query pagination seems to be a huge question for a lot of people) so I'm trying to narrow down exactly how to make it function. I'm able to create a ...
1
vote
1answer
51 views

WP_Query post_parent parameter always returns children of current page

Well the title gives it all away... Here's the code: $args = array( "post_type" => "page", "post_parent" => $cat, // runs through a loop of 5, 128, 130 "posts_per_page" => -1 ); ...
0
votes
0answers
46 views

WP_Meta_Query object with conditionals

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
1answer
46 views

List of ways to access WordPress database?

I'm trying to get a complete understanding of how WordPress works with databases. I've read the documentation but I'm getting confused by all the different approaches available. So far my ...
3
votes
1answer
81 views

WP_Query to work with custom view

I have created a Database VIEW on wp_posts which selects its all columns and exposes an extra calculated columns (average). So my View is identical to wp_posts plus one column, which I want to use for ...
0
votes
2answers
23 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, ...
19
votes
4answers
15k views

Using wp_query is it possible to orderby taxonomy?

My question is simple, I'm using WP_Query to retrieve some custom type posts filtering by a taxonomy using tax_query. Now my problem is I would like to orderby the taxonomy, but from documentation ...
0
votes
0answers
57 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
39 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
1answer
50 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
41 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
0answers
21 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
43 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
26 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
23 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
38 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
65 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
1answer
27 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
0answers
23 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
30 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
6 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
2answers
47 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
27 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
52 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
40 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 ...