"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
9 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', '...
0
votes
1answer
23 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
11 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
0answers
11 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? $...
1
vote
1answer
22 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
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 ...
0
votes
1answer
47 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
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
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
57 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 = (...
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'); ...
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
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
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( '...
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 ...
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' =&...
-1
votes
0answers
18 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
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' =&...
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
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 ...
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 ...
0
votes
1answer
92 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 (...
0
votes
1answer
29 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
29 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 ...
-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( ...
0
votes
1answer
35 views

Add post class in custom loop (WP_QUERY)

Normally if I wanted to add a custom post class I would use the post_class filter. However, when using a custom loop the post_class filter is not accessible. I am trying to apply classes that will ...
-3
votes
1answer
43 views

Group posts by year in loop

How can I separate posts by year in archive page for Custom Post Type? while ( have_posts() ) : the_post(); the_title(); the_post_thumbnail('thumb'); endwhile; The end result would look ...
0
votes
1answer
33 views

WP_Query with rewind_posts creates duplicate titles

I have a WP_Query with rewind_posts that I use to filter posts if they belong to a particular category. Basically, if any post belongs in a category with First, it goes to the top of the list. The ...
0
votes
1answer
52 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
0answers
24 views

Wordpress Query OR relation between “tag__in” and “Search Keyword”

I am Working on custom search, there i can see default relation is AND in query. My query Args is: $query_args = array( 'post_type' => 'post', ...
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
12 views

How to control or select category layout(4post) from backend

I have layout of 4 posts to show 4 posts in the index and I am using WP_query to display the layout but I want to make my theme more easier by selecting the category from the back-end, rather than ...
3
votes
1answer
52 views

How to hide post content/meta from everyone except the post author and admin

I'm trying to start myself off here but I can't get my heard around it... How can I hide and author's post content/meta from everyone except the post author and admin? This is my scenario... Schools ...
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 ...
0
votes
1answer
30 views

Custom taxonomy and query multi conditions

I have this query $query->set( 'tax_query', array( 'relation' => 'OR', array( 'taxonomy' => 'location', ...
-2
votes
0answers
19 views

Hoping someone could explain some queries for me

The following queries are considerably slow on my site and I'm hoping someone could explain them to the best of their ability (what they're doing/requesting). SELECT SQL_CALC_FOUND_ROWS wp_posts.ID ...
0
votes
1answer
37 views

Filtering out child category posts from parent category archive not working

In this example cat 5 is the parent category, and 42 is a sub-category. I the main category 5 archive I don't want any posts from sub-category 42 displaying. Why isn't this working? function ...
0
votes
1answer
30 views

Get posts for custom post type with WP_Query

I'm trying to make a custom post return a query and display but instead it is returning and showing the default/standard post. How do I get posts from my CPT? $query = new WP_Query( array( '...
0
votes
0answers
12 views

Query CPT's by 'weight'

Bit of a strange title but I'll explain it soon. I'm working on a site that should show many types of sponsors. I've created a CPT for them and a custom taxonomy. The client has three types of ...
0
votes
1answer
12 views

Wordpress query with items from more than one selfdefined taxonomy as `term` argument

So I'm working with a bought version of a plugin (WP Catalogue, sorry I can't post more links than 2) as basis for my code for a website i'm working on and i'm adjusting it so that it can be used for ...
1
vote
0answers
24 views

Search for “2nd” also returns “22nd” in wp_query

I'm using wp_query to search a string: $args = array('s' => '2nd','posts_per_page' => '-1',); I'm looking for the 2nd of the month but it is also returning 22nd which is pragmatically correct,...
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 ...
0
votes
0answers
16 views

wp_query query with two custom posts shows all post instead of matching ID

I have two types of custom posts - a "neighborhood" and an "area". Either of these can belong to a "base". When I am querying just the "neighborhoods", the base page has no issue pulling up the right ...
0
votes
1answer
40 views

Persistent Shortcode Attribute Variables using WP_Query and WP AJAX

I'm trying to: list posts using a shortcode using WP_Query have that list use pagination have that pagination use AJAX ...and - where I'm getting stuck - manipulate my list via shortcode attributes ...
-4
votes
0answers
21 views

Creating custom functions with wordpress

Can any one help me out with this: how can I write the functions: Write a custom php function in functions.php for salient-child get_event_member_product_url(post_id). In this function, when a post ...
0
votes
1answer
28 views

Populate tax_query terms parameter with post term

I need to populate the terms parameter in my tax_query with the current term of the post. I have been trying to use the WP function wp_get_post_terms in a variable and then referencing that variable ...
0
votes
2answers
35 views

date_query won't accept day parameter, but will accept month and year for a custom post

I have a frustrating issue. I am using the date_query as referenced in the Codex: <?php $today = getdate(); $args = array( 'post_type' => 'Lighting', 'post_status' => 'publish'...
-1
votes
0answers
25 views

Disable Pagination while limiting the number of Post to be displayed

I want to disable pagination and also limit the number of post to be displayed. I am using two query on same page with different arguments. First one displays all posts while the second one should ...