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

Order ascending is ignored in meta query?

I'm using pre_get_posts to alter my main query and attach a meta query to it. This is on a woocommerce products archive page (...not sure if that would make a difference). function has_upcoming_date(...
0
votes
1answer
25 views

DIsplaying URL of custom field in last post of certain taxonomy && post type

So, I need to echo the URL of a custom field from the last post published in a certain post type and with a particular taxonomy. This code so far works OK, but even that numberposts = 1, $...
-1
votes
0answers
20 views

What is the one-query (or the fastest) way to get posts and their terms (more taxonomies)?

Now this might seem like a similar question One query to get posts and their taxonomy terms but it is just similar and does not have proper answer. Goal: I need to get limited number of posts and ...
0
votes
0answers
14 views

WP Meta Query at depth 2

I'm interested in doing a meta query according to some post data that doesn't exist at the first level of the post meta. In other words, I would need two or more keys to get to the variable I'm ...
0
votes
0answers
17 views

How to select N number of products and display it randomly in Woocommerce

I have a woocommerce setup with about 10,000 products, i would like to display all the latest products on the home page so that i can have N number of latest products from each PRODUC TAG displayed in ...
0
votes
0answers
10 views

How to add OR condition in wordpress main seach box Query?

I'm trying to search from main search text box. Custom post type "course" and it custom taxonomy 'Location'. It I search with "USA", In data it looks for 's'= 'USA' AND 'loaction'='USA'. What I ...
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
0answers
24 views

When will they make it possible to exclude post types from an wp_query?

Very simple, when I am setting up the arguments for an wp query, I can't exclude post types. While it is possible to include them, I would love to see an excluding possibility. Is there any ...
0
votes
1answer
18 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
25 views

Only Get A Certain Number of Posts From WP_Query

I'm not sure what I'm doing wrong. None of my WP_Queries are returning the given number of posts. From what I can tell, it's returning all of them. How do I fix this? Here is the code I'm currently ...
0
votes
1answer
42 views

Exclude current post from an array of posts?

I'm trying to exclude the current post from an array and I know that the codex says that it's not possible to combine post__in and post__not_in in the same query... But in wordpress everything (well, ...
0
votes
0answers
23 views

Wordpress Pagination archive/category [duplicate]

I have a problem with creating a simple pagination for the categories with WP_Query. I've got it to work for the archive, but if I try the same on the category template, then I get redirected to the ...
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. ...
-1
votes
0answers
21 views

Pagination creating an extra page with no posts

I have a wp_query with the following $args: $time = current_time( 'timestamp' ); // Get current unix timestamp $cpt_posts_per_page = ( is_front_page() ) ? 4 : 8; $paged = (get_query_var('paged')) ? ...
0
votes
2answers
40 views

display post multiple times based on array of dates

I have a custom post type for a simple schedule list and using the meta box plugin i have two meta boxes assigned to custom post type. 1 for an image and 1 for an array of date times . In my ...
4
votes
1answer
98 views

author.php with ACF and CPTs

As I write this, I'll do my best to avoid an XY Problem. What I'm trying to do: I'm trying to build an author.php template that: displays data from Advanced Custom Fields on the user's Profile ...
0
votes
0answers
23 views

How to use get_posts on a secondary loop [on hold]

I feel like I am missing something terribly obvious. I have set up my secondary loop and it returns the_title() and the_post_thumbnail() as expected, but I am also using the Advanced Custom Fields ...
0
votes
0answers
31 views

Display most popular in the past two days

Hi I'm using this code below to display the most popular post on my wordpress site. It works great! I was wondering if there was anyway to show the most popular post of the current day? This in my ...
7
votes
4answers
246 views

Is it possible to completely stop WP_Query retrieving posts?

I'm trying to use WP Redis to cache entire $wp_query object with key is $query_vars_hash. This is how $wp_query was added to $wp_object_cache: add_action('wp', function($wp) { if ( is_admin() ) ...
6
votes
1answer
60 views

How to remove_query_arg() for paginate_links()

I implemented a pagination using paginate_links() like below: <?php function wpse229670_pagination( $query = false ) { global $wp_query; $query = $query ? $query : $wp_query; $...
3
votes
1answer
84 views

Using WP Query to search within ALL keys in meta query

What is the best way to create a meta query that searches through ALL meta fields (keys)? What I'm trying to do is something such as: $posts = new WP_Query(array( 'meta_query' => array( ...
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
0answers
29 views

Custom Page Load by wp_query

Is there a way I can use wp_query to retrieve custom pages and posts, and display them on the front page of my WordPress site? I'd like to do that for every custom page I have, to end up with a one-...
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 ...
1
vote
1answer
28 views

Custom query, checking values of multiple meta keys

I am using two plugins, and I have some issues combining them. One is an event calendar, which add new meta keys to posts, the other is a show-posts-as-grid plugin, that fetches the event posts from ...
0
votes
0answers
27 views

How to format a WP_Query using groupby and orderby meta value

I have a messenger in my app that uses a custom post type to store messages. I have two ways of showing these messages in the front end of the app: conversations and messages. Every message gets 2 ...
1
vote
0answers
44 views

Custom Pagination in Shortcode with WP_Query

Trying to add custom pagination within a visual composer shortcode. The get_next_posts_link() and get_previous_posts_link() functions are working fine, but when I try to add the pagination function, ...
0
votes
1answer
25 views

find posts that don't have a custom taxonomy

I am using a custom taxonomy series to keep track of posts that are in a series. I would like to find the posts that do not have a series. I have the following query: global $wpdb; $pr = $wpdb->...
0
votes
0answers
37 views

Sort custom post type by a custom field from another custom post type

I have a custom post type called "listings". When adding/editing the listing, the user can choose enter the ID of a "Plan". I also have a custom post type called "plans" which contains some fields ...
0
votes
0answers
13 views

how to solve pagination error in category.php file [duplicate]

Now i have four category in my site. i can get all the pages of one category which is tour category and if i click other three i can see first page but if i click to second page it gives page not ...
0
votes
0answers
43 views

How do i get category name dynamically?

I have a page category.php. but i have more category for pages then i want display all the related category pages in category.php page. how can i change category_name dynamically when user click ...
0
votes
0answers
24 views

Using custom query on a custom page for a custom post type

I have setup a custom page (page-mypage.php) and I want to list all posts of a custom post type when I use the loop in my custom page. I'm using pre_get_posts hook to modify the query. Problem: In ...
0
votes
1answer
27 views

Query only displays one page_id

I have a short query that is supposed to load IDs from pages that the user picks in the backend. Currently it does display an array with IDs on the frontpage, but it stops displaying posts after the ...
0
votes
1answer
28 views

Filter by title content and meta key at the same time

Using: $query = new WP_Query(); How do I filter to get records with titles OR content OR meta keys which contain a part of a string. I currently have $args=array( 'order'=>'asc', ...
3
votes
1answer
49 views

Order terms inside a select dropdown

I'm working on a project where I've a dropdown of all the terms inside a taxonomy. If the user selects a term, then a function is executed. Eveything is working great, but I can't get that dropdown ...
1
vote
1answer
20 views

Adding an array from a query string to a WP meta_query

I am collecting values from a query string as an array. Then collecting those values and placing them into the value of the 'meta_query'. I am having trouble where nothing gets outputted from the ...
0
votes
0answers
33 views

WP Query with sticky posts and tax_query

I have this query; $posts = new WP_Query(array( 'post_type' => 'post', 'posts_per_page' => 5, )); Which correctly places sticky posts at the beginning. However,...
-1
votes
2answers
50 views

Filter posts by category

How can I get posts from a specific category on a custom category page? The below code gets the posts from all categories but I can't find a way to filter according to a specific category. Can ...
0
votes
1answer
31 views

How to exclude a category name from showing?

So I'm trying this code: <?php global $post; $my_query = new WP_Query('showposts=8&category_name=featured'); while ($my_query->have_posts()): $my_query->the_post(); $...
0
votes
0answers
15 views

Display posts in a custom taxonomy, grouped by a different taxonomy

The setup: I have a custom post type called products. I have a custom taxonomy called styles with terms modern, classic, rustic. I have another taxonomy called seasons with terms fall, winter, ...
0
votes
0answers
17 views

Pick date, month or year from publish date to set up Query

I run the query with order by date. it shows something like this. 2016-5-30 : hello world 2016-5-10 : hell world 2016-4-30 : Title A 2016-4-15 : Title B I want to add one option. Can I pick the ...
0
votes
2answers
21 views

Custom WP_QUERY $args

I have an SQL query here: $data_listg = $wpdb->get_results( "SELECT ID FROM " . $wpdb->prefix . "posts where post_type='post' and SUBSTR(" . $wpdb->prefix . "posts.post_title, 1, 1) LIKE '%$...
0
votes
0answers
20 views

Filter with 'OR' relationship between child categories, and 'AND' relationship between parent categories?

I have a some categories set up like so: Age Child Teen Adult Language English Spanish French Relevant code below: $cat = (isset($_GET['cat'])) ? $_GET['cat'] : 0; $args = array( ...
0
votes
0answers
25 views

Can't get get_delete_post_link to work correctly

I am using WP_Query to to list all of a certain CPT for each user. Everything is being displayed correctly, but for some reason get_delete_post_link isn't returning anything. Does anyone see what ...