"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
1answer
11 views

How to make Meta Query case sensitive?

I have a meta query similar to: $posts = new WP_Query( 'post_type=article&meta_key=kln_aid&meta_value=' . $aid ); where I need aid to be case-sensitive. Is that possible via Meta Query?
0
votes
0answers
11 views

Select Unique Posts for a List of Tags

I have a query returning a list of tags based on my search criteria. I am looking for a way to return a list of posts for these tags however I would like to exclude redundant posts from the results. ...
-1
votes
3answers
77 views
+50

Adding a blog archive with pagination using WP_Query

I have the following code:- <!-- News Archive --> <div id="news-archive"> <div class="row"> <div class="col-md-12"> <?php $paged = (...
1
vote
2answers
24 views

How to change admin menu position of “Media”?

I would like to change the priority/menu order of the "Media" admin page. Is there a way to change that via apply_filter? Is there a way to change only "Media" page priority without having to list ...
0
votes
1answer
8 views

Get all post meta for post where on meta key is a certain value

I have a meta key which I would like to use to get all post meta data for a post where that one meta key matches a specific value, in one go. Example: Post 1 has a meta_key called unique_number. I ...
0
votes
1answer
60 views

Bring a post to the top of the query if it's in a certain category?

I'm looking for a way to bring a post if it's in a certain category to the front (or top) of the list. The category is called 'first'. I don't think orderby supports category so what other options do ...
0
votes
1answer
1k views

Group posts by meta_key

I have a Problem with grouping meta_values. The Query looks for posts with the meta key "company". I want a unique listing of the colors like: blue red yellow array_unique was not successful and also ...
0
votes
1answer
95 views

Merging a complex query with post_rewind and splitting posts into two columns

I need help with my query that uses rewind_posts so that if a post is in a particular category, it moves to the top. What I would like to do is have a query that splits posts into a two-column page (...
1
vote
1answer
584 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 ...
0
votes
0answers
11 views

Order by string custom field not working

I want to sort posts by a custom field but I don't know why the following query doesn't work (returns the posts in the default order): $args = array( 'post_type' => 'proyectos', '...
1
vote
1answer
24 views

Most viewed post for the last 2 days using WP_Query

Hello I have code intended to get the most viewed post for last 2 days and it seems like not working or maybe my code is just incorrect. I appreciate any help. Thanks. $args = array( 'post_type'...
0
votes
1answer
25 views

query_posts() doesn't seem to be called in my page

I've a problem with my query_posts() call. Here is my code: $results = $wpdb->get_results("SELECT post_id FROM " . $wpdb->postmeta . " WHERE meta_key = 'mashsb_shares' ORDER BY CAST(meta_value ...
0
votes
0answers
12 views

Query Top Set Custom Taxonomy In Given Timeperiod

Just an example but, The results should be the top 15 used terms in the taxonomy genre in the past 24 hours. My thoughts were to query all posts from the past 24 hours, get the terms list, and ...
0
votes
2answers
2k views

Pagination doesn't work

I created myfile.php with the following content: global $paged; if ( get_query_var( 'paged' ) ) { $paged = get_query_var( 'paged' ); } else if ( get_query_var( 'page' ) ) { $paged = ...
0
votes
0answers
13 views

WP_Query sorting by Taxonomy

I am trying to display the custom post type of accommodation that have a the location of wa under the Location taxonomy. Although i am not having any luck. Can anyone tell me what i'm doing wrong? $...
0
votes
2answers
39 views

Assign custom parameter to each post in query

I'm trying to add an incremental variable to each post that comes up in a series of queries. The purpose is to calculate a weight for each result in order to be able to order everything later. This ...
1
vote
1answer
3k views

Ajax load more posts - WP_Query parameters not working

I'm trying to replace the standard WP pagination with an Ajax load more posts button. I'm basically following the code from this question which for the most part works well. Here's the relevant code:...
0
votes
1answer
32 views

WP Query - filtering terms with regex

is there a possibility of filtering posts by terms using regexp? My code doesn't quite seem to work. $tax[] = [ 'taxonomy' => 'tax_name', 'field' => 'name', 'terms' => $...
0
votes
1answer
48 views

Query posts only without featured image

want to query 100 posts, but only those which do not have a featured image attached. I am using meta_key method for this with WP_Query as such: $args = array( 'post_type' => 'post', '...
0
votes
1answer
20 views

Post Thumbnail URL isn't pulling into the background of div

I updated my code. I swapped returns with echoes. The only issue is that the post_thumbnail_url isn't pulling into the background of div. <?php $args = array( '...
0
votes
3answers
59 views

Is temporarily overwriting $wp_query a bad idea?

I am in the process of rewriting a lot of my code and restructuring a lot of my theme files to use template parts (i.e. using get_template_part()). I've come upon a situation where I want to use the ...
1
vote
1answer
710 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 ...
0
votes
2answers
646 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: $args = array( //'post_type' => $posttype, 'post_type' => explode( ', ', $posttype ), ); ...
1
vote
1answer
993 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 - ...
0
votes
0answers
14 views

Get all post order by meta_key above 0 value

I'd order post by meta_key but i've a problem with meta_value because is some post have (0) value, So my query get only all post have valure above (1) value. <?php $week = date('W'); ...
2
votes
1answer
813 views

Reduce or prevent calling of update_meta_cache

My theme calls the update_meta_cache() function 58 times per page! This function appears to run the following query based on the post in question: SELECT post_id, meta_key, meta_value -> FROM ...
0
votes
1answer
19 views

Add class to first post in custom loop using post_class filter

I am trying to add a class to the first post in a custom WP_Query. I can add a class to the first post of the standard WordPress loop using; add_filter( 'post_class', 'featured_classes' ); function ...
2
votes
3answers
7k views

How to make WP_Query 'post__in' accept an array?

I have a function that returns a comma separated list of post ids that a particular user can access. I want to use this list in a WP_Query loop. The custom function: $array = user_albums(); foreach( ...
0
votes
2answers
768 views

SQL returned by Wp_Query has wp_posts.ID = -1

I have a custom loop based on these arguments (below), and for some reason when it's run, the SQL returned has this fragment: ... AND wp_posts.ID = -1 ... And I get no results from the db. If I run ...
2
votes
2answers
849 views

Pagination problem after WP_Query with tag filtering

I have a problem with a custom WP_Query. I want a page with all posts with a specific tag. This is the code I'm using: <?php //save old query $temp = $wp_query; //clear $wp_query; $wp_query= ...
4
votes
2answers
601 views

Display recent posts from the same category as current post in sidebar

I'm using a modified version of Twenty Twelve and I'm trying to display recent posts from the same category as the current post (except the current post) in the sidebar. I started this way but ...
-2
votes
0answers
14 views

get_categories - how to replicate with WP_Query?

I have a slider on my front page that makes use of WP_Query and there fore uses the_post etc like this: $feat_query = new WP_Query( $args ); if ($feat_query->have_posts()) : while ($feat_query->...
0
votes
1answer
26 views

How to modify WP Query to target the first most recent post to adjust content

I'm working with a function to grab the 3 most recent posts from the category "news" add_shortcode( 'show_news', 'news_query' ); function news_query() { $args = array( 'posts_per_page' =&...
0
votes
0answers
20 views

How to take parameters from a function and make them editable as attributes in a shortcode

I want to make shortcodes easily editable for the user, how can I modify this shortcode: add_shortcode( 'show_news', 'news_query' ); function news_query() { $args = array( '...
0
votes
1answer
23 views

Modify query to exclude certain ids and certain parents and its corresponding children

I'm trying to modify an admin query where I need to exclude a few pages based on two conditions: Exclude based on certain titles Exclude based on certain pages, including its children pages To ...
1
vote
1answer
18 views

Complex date range with WP_Query and BETWEEN

Backstory We have a bunch of events inside an events custom post type. They each have the following custom fields associated to them: start_date end_date On the front-end, we have a sidebar with ...
3
votes
1answer
58 views

Setup of taxonomy term template pages

I'm wondering if the following setup can be more efficient without creating an taxonomy term page for every custom taxonomy term. I'm working with courses (CPT) which has it's own taxonomy (Course ...
0
votes
0answers
40 views

How to query all posts and only show the first 6?

I currently have the following code: <div id="news-archive"> <div class="row"> <div class="col-md-12"> <?php $args = array( 'post_type' =&...
-1
votes
0answers
19 views

How to Change the Custom Media Upload view to Default View

My client has a custom theme which's has a custom option for selecting the featured image for any post. The current default view for selecting the featured option is "Uploaded to this post only". ...
0
votes
0answers
15 views

Condensing Query with Append

I have a form that has 3 fields: Genre, Label, Era. Depending on if the field is left blank or not, I need to do a different query. At the moment, my code works perfectly fine but is not very ...
0
votes
1answer
1k views

WP_Tax_Query with post_tag not working

Using the pre_get_posts hook, I'm trying to allow users to narrow down their search by limiting it to posts with certain (multiple) tags applied. This is my hook and function: add_filter('...
0
votes
0answers
16 views

Get array of parent and other child categories based on one child

I'm trying to modify a custom wp_query that's generating related posts. Currently, it's returning other posts in the same category, which is a sub-category. I'd like it to ALSO return posts from the ...
0
votes
0answers
13 views

Orderign WP_Query results by 2 variables

Reposting since I think I messed up the original post and it got rejected... I am trying to figure out the args for a WP_Query that will return products that are ordered by first one custom variable ...
0
votes
0answers
22 views

WP_Query results ordered by 2 variables

I am trying to figure out the args for a WP_Query that will return products that are ordered by first one custom variable and then sub-ordered by a second custom variable. The two variables I have ...
1
vote
1answer
560 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
564 views

Can I make a search query which includes a space?

I want to search via WP_Query for the test "hello " including the last trailing space. Is this possible and if so, how do I do this?
0
votes
1answer
31 views

Create an archive page for custom post type with custom taxonomy

I have a custom post type called 'news' with a custom taxonomy called 'news category'. I'd like to create a wp query to return all 'news' posts of a certain 'news category' for example 'press'. Is ...
-1
votes
0answers
30 views

Shuffling Posts On First Load?

I have a category with 20 posts and I would like to shuffle the posts on the page for each individual user that visits the blog. I don't want the posts to constantly change order on reload, so what ...
0
votes
2answers
43 views

Order Posts By Youtube Views

I have a wordpress website where I post song lyrics. I have written a wp query to list specific posts and order them by post views. However, I would like to order them by youtube views instead. I ...
-1
votes
0answers
19 views

Custom Query With Meta Value

I want to get my posts from the "cafe" post type with this filter, but it doesn't work. This is my custom query: $args = array( 'post_type' => 'cafe', 'meta_query' => array( ...