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

Query custom post type with tags

I created a custom post type named portfolio, and am trying to create a query to get similar posts from the portfolio post type based on if it has at least 1 similar tag. For some reason this code ...
0
votes
1answer
26 views

Use WP_Query in shortcode

I'm trying to get meta information from the first four posts that have a meta key equal to Sedan, then format that posts meta in order to set up gallery type display boxes. I believe it has something ...
0
votes
1answer
23 views

Inner join overrides Advanced Custom Fields plugin's get_field

I have this search that I made with inner join and where clause. I no longer get get_field() values, they all return false. How can I get ACF to work again? It must be something silly that I don't ...
0
votes
1answer
18 views

How to add div blocks after certain set of post

Ok I broke my post down into different style settings. Like shown below. The first post is a large block. the next four post are small and aligned next to the larger post. I used the loop below to ...
0
votes
0answers
19 views

How to solve this script problem in theme directory?

I have a jQuery Ajax call that calls a php script. This call works if the file is in the root of the site but does not work if this php script is in the theme folder . Additionally, I have a 500 error ...
0
votes
0answers
8 views

MySQL query in Functions.php using inner join to override/add to search

I'm setting up a radial geo-location search. I have users select a zipcode and a radius to search within. I want to use the regular search site.com?/s=abcd&zipcode=90210&radius=10 I look up ...
0
votes
0answers
12 views

WP_Query relation AND with two taxonomies and orderby rand, prioritising one taxonomy

I have a wp_query which selects posts from a CPT, using relation AND to select posts from two taxonomies (sector and expertise). I would like the order of posts returned to be random but I would still ...
1
vote
1answer
32 views

How to pass many ids in post__in?

I need to pass many ids to the parameter post__in in args. This not work !!! Help me please. foreach ($rows as $obj) { $todos .= $obj->ID . ","; } $ids = trim(trim($todos), ","); # echo ...
1
vote
1answer
43 views

How to use WP_Query to display many posts?

This is my WP_Query instruction but this not work. This display just first post. Help me please? // WP_Query arguments $args = array ( 'post_type' => 'teachers', 'p' => ...
0
votes
2answers
38 views

How to order WP_Query to group results?

I have a list of products in WooCommerce that have titles like so: Please note: The "groups" are just for myself, they are not categories etc. All products are the same type of product, just two ...
0
votes
0answers
7 views

Get custom meta box in custom post type using tag ID

I have a custom post type called Contacts, and in each of those post I have a custom meta box called number where a phone number is stored in each of the Contacts posts. I also have a custom taxonomy ...
0
votes
1answer
28 views

WP Query to Get Array of Slugs

So I will be using a template where posts have related products (woocommerce) as defined in the custom fields. I've just got a load of slugs and I dunno how I can query the array of slugs. Heres what ...
0
votes
0answers
23 views

extract shortcode_atts with multiple meta key and meta value

I am trying to extract( shortcode_atts( array( arry with multiple meta key and value in bellow snippet code you can see that i am extracting shortcode_ats with bellow code ...
0
votes
3answers
38 views

Sort the main query in subcategories/terms?

I've got a 'downloads' custom post, with his custom taxonomy. The taxonomy has 2 main terms. One of the 2, has 4 sub-terms. I'm currently using the wp templating system to get a standard wpquery of ...
0
votes
1answer
24 views

How to query Posts from a custom post type which contains a custom taxonomy?

I have the following: $queryResponse = new \WP_Query(array( 'post_type' => 'portfolio', 'tax_query' => array( array( 'taxonomy' => 'portfolio_date', ...
1
vote
1answer
17 views

How can i make WP_Query return post image and categories?

I have a sidebar widget that will display related posts based on a custom meta field. The query works, but its very wasteful. All i need is the post title, featured image and the categories of the ...
0
votes
1answer
16 views

Empty tax_query array returns an empty array

I would like to return all posts when the tax_query['terms'] is empty. $args = array( 'post_type' => 'product', 'posts_per_page' => 15, 'paged' => $paged, ...
0
votes
2answers
21 views

How to Insert data with wp cron

I am using wp_schedule_event for Insert data every 1 Minutes in a teble. But here is some confusion where i have to add code for Insert. Here is my code which add in functions.php in my theme. ...
0
votes
1answer
35 views

Get the post permalink within the loop but without additional DB query

I am looking to create a custom 'directory' page which will link to several thousands of posts. Because of the large number I am trying to limit the number of DB queries. I notice that to link to each ...
1
vote
1answer
34 views

Display posts from only one post form in custom query and exclude in main query

I am trying to first display four posts with post-format-aside (all assigned to current tag) and then display the "real" archive (exclude post-format-aside) for the specific tag. Right now I am using ...
0
votes
0answers
20 views

query.php - multiple is_category functions

Why does query.php have multiple is_category functions?! E.g. in my version of WordPress (4.x) I have in query.php: line 230: function is_category( $category = '' ) { line 4095: public function ...
0
votes
0answers
12 views

Debugging - is_category()

I'm trying to work out where WordPress decides if a URL is pointing to a Category or not. I've got to this function in query.php public function is_category( $category = '' ) { if ( ...
0
votes
0answers
23 views

Pagination not working Search posts

if ( have_posts() ) { while ( have_posts() ) { the_post(); global $post; //loop here } if(function_exists('wp_pagenavi')) { wp_pagenavi(); } } I have the following code in function ...
2
votes
1answer
34 views

Get taxonomy description based on variable

I'm trying to display a taxonomy description based on which taxonomy the page is set to display (set with a variable) As it is, I'm only seeing the first description, regardless of which category ...
0
votes
0answers
30 views

Breaking WP_Query loop into rows with variable width columns

I'd like to create a Boostrap grid of posts where sticky posts take 6 columns (.col-md-6) and normal posts take 3 columns (.col-md-3). Posts to be sorted dynamically. So in one row there might be ...
0
votes
1answer
18 views

Multiple loops without repeating content

I have a second loop on a page where I want to display posts from the same category as the present post but excluding the present post. I have a loop that displays all the posts from the same ...
0
votes
1answer
27 views

Pagination not working Category posts

I am using https://wordpress.org/plugins/wp-pagenavi/ pagination and because of certain reason I have "blog pages show at most" set to 100 and i can't reduce it. I have total 30 posts in a category. ...
0
votes
0answers
18 views

Query posts by category and tag_id [closed]

I have a query which looks like this: <?php $args = array( 'post_type'=> 'user', 'showposts'=> -1 ); $users = new WP_Query($args); echo '<pre>' ...
0
votes
0answers
14 views

GUID to related post not in current language

I'm having problems with related posts and the link to them. I'm using the plugin Posts 2 Posts to create connections between posts. I also have three languages in wordpress website (french, ...
0
votes
1answer
58 views

Convert a WP Query into a simpler SQL query to fetch only COUNT of posts

I have this WP Query running for each row in my admin screen for a certain post type: $entry_args = array( 'meta_key' => 'wp_comp_entry_competition-id', ...
0
votes
0answers
11 views

WP_Query filtered by simple checkboxes

I'm trying to build a WP_Query with specific filters, i.e., checkboxes and radio buttons. The checkboxes will filter the meta-data linked with my custom post type. The meta-data is the location. And ...
0
votes
1answer
41 views

WP_Query with MetaQuery issue

I'm facing a rather strange issue when attempting to pass in four different meta_query values to my WP_Query. Find below an example of my WP_Query search. Please bear in mind, if I remove and test ...
0
votes
2answers
54 views

Pagination for custom loop on custom page template is not displaying anything

I have created a page where user can see his favourite post which has been bookmarked by him get_user_favorites($user_id); This function is responsible for returning me all the favourite posts ...
0
votes
1answer
17 views

meta_value timestamp older than now

In my wp_posts table I want to select the rows where post_type == event. I also want to a connection with wp_postmeta from the specific row. In my wp_postmeta table I want to do a where like this: ...
1
vote
1answer
25 views

Hide Post comments when displayed via WP_Query

I've written a shortcode which displays 'x' number of posts on the homepage of my site when I write [blog posts_per_page-"3"]. Here it is: function getBlogPosts($atts) { ...
2
votes
2answers
39 views

Query sticky posts with thumbnails

I need to display max 5 latest sticky posts that have a thumbnail. And I need to have accurate counting of the displayed posts. I've tried to exclude sticky posts without a thumbnail with meta_query, ...
1
vote
1answer
25 views

Show Sticky Post at the top but do not show again in the loop?

Regarding wordpress.org - sticky posts are displayed at the top but they also appear again in the loop. For the main loop on my homepage I want to display the sticky posts at the top BUT I don't ...
0
votes
1answer
33 views

WP_Query custom query showing only 10 posts on all pages

WP_Query custom query showing same only 10 posts on all pages when set to 5. Here is my code: Updated code: <?php global $wp_query; $paged = (get_query_var('page')) ? get_query_var('page') : 1; ...
0
votes
1answer
25 views

Display posts by tag

I'm trying to display a list of posts by tag within a post. I've cobbled together the following code which I wanted to use in a shortcode, but I'm getting nothing displayed… $args = array( 'tag' ...
0
votes
0answers
17 views

Get X posts for all post types on Taxonomy term archive

I'm working on a tabbed archive page for taxonomy terms. Ultimately, I want each tab to show the 10 most recent posts for an individual post type with a "see all" link at the bottom of the tab that ...
1
vote
0answers
67 views

meta_value_num not ordering all items

I am using meta_value_num to output a list of items in order by a custom field. The custom field value that is being passed is 1, 2 ,3 or 4. The order works for the first 7 items but after that they ...
0
votes
2answers
77 views

Only display post if published in last 24 hours?

All I'm trying to do here is a simple custom loop using WP_Query to display posts if they are published in the last 24 hours; otherwise, a message appears telling the user to check back soon for fresh ...
0
votes
1answer
28 views

wp_query with custom post type only returning last posted

i am using wp_query to get posts for a custom post type but it is only returning the most recently posted item. This is both in the returned object and within the loop: $wp_query = new ...
0
votes
1answer
36 views

Custom query with post_class filter using current_post not working

I have a new WP_Query on my archive page. I also have a post_class filter conditionally adding a class of first so I can display them in rows of 3 reliably. This is the post_class filter function ...
0
votes
0answers
21 views

How to achieve an elegant way when using ajax to get data for a table in WordPress?

I'm working on the update for a website which wasn't originally developed by me. The task is to have a table on a main page and, if you move a slider with value on it (100, 200, ... 1000), the table ...
0
votes
1answer
30 views

Does putting queries within loops cause an issue on Wordpress?

If I include a new wp_query within another query's loop (e.g. putting even a very simple query, like the ones from the codex example on a single page template) the page loads as expected, but the ...
0
votes
1answer
22 views

Trying to list out child pages with WP_Query

I'm trying to list out all the child pages of a custom page I've made. In my custom page, I'm doing this to list out the pages: <?php get_header(); ?> <?php $subpages = new WP_Query( ...
0
votes
2answers
37 views

WP_Query Posts by Metadata from Option Tree

I am doing a WP_Query trying to filter out the posts by Metadata. $args = array( 'ignore_sticky_posts'=> 1, 'post_type' => 'post_projects', 'post_status' => 'publish', ...
0
votes
3answers
29 views

Stylesheet won't load even when linked

I don't know what I'm doing wrong here. I created a page with accordians, the jquery script loads just fine but when I link the CSS stylesheet, no CSS shows up. It is not an external stylesheet, I ...
3
votes
1answer
83 views

Use REGEXP in WP_Query meta_query key

I know I can use REGEXP in WP_Query like this: $query = new WP_Query(array( 'posts_per_page' => -1, 'post_status' => 'publish', 'meta_query' => array( array( ...