"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

3
votes
0answers
123 views

Custom WP_Query order by post_meta and (author) user_meta

I am having an issue that i couldn't find on google and elsewhere. To put problem in the context. I am making a wordpress site where user can put their tutor listing for giving a tutorials, and i am ...
3
votes
0answers
754 views

Display one post from each term in a custom taxonomy

I am trying to display a list which shows one post (and information about the person posting) from each custom taxonomy term. The code I am using is as follows, but it is instead printing out EVERY ...
3
votes
0answers
94 views

Get page content by category or tag

I'm trying to sort of emulate the Views behaviour in Drupal with Wordpress, but doing it in theme templates. Now, I have pages that are assembled by using wp_query in the template to get posts ...
2
votes
0answers
33 views

Number of pages - multiple (custom) post types

My archive query contains a custom posts_per_page, order, orderby, post_type and paged (via wp-pageNavi). array ( 'order' => 'DESC', 'orderby' => 'title', 'paged' => 1, '...
2
votes
0answers
27 views

Get posts with condition on comment meta value

I have to fetch all the posts post_type=projects and post_status=publish which have the latest comment of type message older than 5 days with comment_meta value as key=value. I want to know how can ...
2
votes
0answers
19 views

Select menu should display categories and the item's depth

I have a select menu of a custom post type in the header.php: <?php $selectloop = new WP_Query( array( 'post_type' => 'products', 'posts_per_page' => -1 ) ); echo '<form>&...
2
votes
0answers
27 views

Custom Taxonomy and tax_query Issue?

I am working on Plugin development and my plugin name is plugindev.I have a custom post type called team.I have a custom taxonomy Team_Category which is being registered by this code /****************...
2
votes
0answers
252 views

Warnings in nav-menu when visiting query pages

Using query-wrangler, similar to drupal's views, I created some query pages. When I visit these pages, in the top-navigation-menu there is this warning: Warning: in_array() expects parameter 2 to be ...
1
vote
0answers
19 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 ...
1
vote
0answers
45 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, ...
1
vote
0answers
40 views

Cast woocommerce events date meta_value with wrong format in WP_Query

I'm using woocommerce events plugin to sale tickets in a client site. The client wants to display the next 3 events after today in the home page. I have created this code: $args = array( '...
1
vote
0answers
32 views

order by multiple meta keys in pre_get_posts

I want multiple orderby meta_query eg: orderby(‘_property_price’ => ‘DESC’,’_property_featured’ => ‘DESC’) This is what I am doing $query->set('meta_key',array('_property_price','...
1
vote
0answers
18 views

Query with relation and one without relation using multiple taxonomies?

I'm trying to use one query for two queries, one with an and relation and one without without having to do multiple queries and loops, is this possible? <?php $args = array( 'post_type' =>...
1
vote
0answers
48 views

Using Advanced Custom Field for file upload, how do I load the file url

I'm trying to make a link to the file I uploaded with ACF so that it goes right to the pdf viewer from the Read More link, but I am getting an error here is the code <div class="col-md-6"> ...
1
vote
0answers
26 views

Show all data in database table and make it into an interactive table

I have to make a table where my data from my database can be stored and rearranged with every row. The name of every row should be a link to the function mymanual_edit(). Look at the image for ...
1
vote
0answers
53 views

How to display an other custom post type in a different custom post type's archive?

Background: I need to display all posts of a custom post type called "recipes", that have a specific taxonomy "fish", right under the permalink "www.mysite.com/recipes/fish". What I have done: I ...
1
vote
0answers
98 views

wp_reset_postdata() and wp_reset_query() inside shortcode are not working to reset original page query

I'm implementing a form for a frontend post with a shortcode. The form is processed in the same function, reloading the page: function adicionar_ninhada(){ $user_id = get_current_user_id(); if (isset(...
1
vote
0answers
65 views

Random ajax load only works with posts_per_page set to -1

I created a post loader shortcode, that uses AJAX to load posts. Even though I can set the order and order_by query parameters, the order_by should be random. From what I've seen on the web, ajax load ...
1
vote
0answers
61 views

Array Chunks and Inserting Varying HTML in WP_Query

I am trying to output the latest 5 posts from my blog. I would like each post thumbnail to populate divs in the following format. <div class="row full"> <div class="large-6 medium-6 ...
1
vote
0answers
42 views

Exclude Category filter from Portfolio section

I am stuck with this since hours and found lots of forum entries about NOT IN, WP_Query, category__not_in portfolio, editing JS/ CSS in Theme options or having bits of code to add to portfolio.php, ...
1
vote
0answers
32 views

Prioritize posts in query by meta keys?

I have a CPT called jobs. In my single jobs page I am counting page views with these functions: /********* Post Views counter ***********/ remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head',...
1
vote
0answers
21 views

Lists Posts from CPT that match the Title of the Page

I am trying to get all the posts associated with the Title of a page. This is what I currently have: <?php $title_to_tag_posts_query = new WP_Query( array( 'tag' => ...
1
vote
0answers
10 views

auto-populating custom nav with all items from custom post type

I have written the following code to take all of the posts in my custom post type "products" (created with ACF) and inject them each as an <li> in a custom nav menu. Everything is working ...
1
vote
0answers
274 views

get product title ID and price and product picture woocommerce by cat-id query select mysql

i have query that return categories in woo-commerce like this: SELECT wp_terms.term_id AS id, name FROM wp_terms INNER JOIN wp_term_taxonomy ON wp_terms.term_id = wp_term_taxonomy.term_id WHERE ...
1
vote
0answers
32 views

Search form not working with custom query?

My search query doesn't seem to work, the query in my url is all correct but the content just refreshes without finding the posts with the search term.. I got a custom search query and a function to ...
1
vote
0answers
29 views

meta_query not working as expected

I have 3 posts that each have two meta values. The first meta value is one that they all share (ac_parent_event). The second is one that is unique to that post (ac_thischild_date). For this function, ...
1
vote
0answers
104 views

ajax category filter

I know this is a big ask for you guys, but i can't seem to figure this out. I found this page : http://www.bobz.co/ajax-filter-posts-tag/#comment-28112 it shows how to make a dynamic filter for post ...
1
vote
0answers
118 views

get posts by meta_key from inside key of post meta

How can i get posts sorted out by meta_key from inner key array of post meta values, for more details please look at my code: // Example output of each post_meta, key is views array( 'all' =>...
1
vote
0answers
23 views

WP_Query's “request” SQL Query

Lets say that I want to use a MongoDB for searching. I saw that WP_Query has a property named request which it seems that holds the SQL Query which is executed on the SQL database. Now if I write a ...
1
vote
0answers
32 views

Pagination inside of a edit page

I looked all over for this and could not find the answer I have two custom post types one is named 'venues' and the other is 'events' every 'venue' has multiple 'events' relating to it. I have a ...
1
vote
0answers
51 views

Combine two queries into one to use in loop

I have two queries. Simplified versions are the following: // First query $args1 = array( 'post_type' => array('post'), 'cat' => '-48', '...
1
vote
0answers
36 views

How can I create a WP_Query that returns posts where one meta_value <= another meta_value

I have a working, pretty complex SQL query hand-written in a function. For the sake of leveraging WP_Query optimizations, and simplifying my code for maintainability, I'd like to convert it all to ...
1
vote
0answers
98 views

inserting a post from an extern php file but post content doesn't show on wp site

I'm doing a php file that insert post's on my wordpress site. I'm filling all the fields in wp_posts, but the content doesn't shows on my wordpress site. I wonder if it's because the categories are ...
1
vote
0answers
34 views

How to : pagination in 3 different custom loops on the same page

I have this content in my index.php. 3 areas with 3 distinct custop wp_query loops to get different categories of articles in each one. I have set wordpress to show 12 articles by page, so it displays ...
1
vote
0answers
24 views

WooCommerce - display category X first

I have 4 categories in my WooCommerce store: Cat1 Cat2 Cat3 Cat4 Is it possible to list them (in asc order) on the shop page as: Cat3 Cat1 Cat2 Cat4 ie, show Cat3 first, then the other ...
1
vote
0answers
280 views

Slow SQL_CALC_FOUND_ROWS Query

We are experiencing very slow performance with queries that use SQL_CALC_FOUND_ROWS within the admin section of WordPress. We currently have about 125,000 posts on our site and use Varnish to cache ...
1
vote
0answers
154 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 ...
1
vote
0answers
249 views

WP Query to have sticky posts first, with pagination and having a joint 'posts per page' arg with main loop

I am building a Wordpress site and have come to a bit of a wall while using a WP_Query, it started out quite simple but then sticky posts got thrown into the mix and it's becoming a bit harder to ...
1
vote
0answers
274 views

Slow WP_Query with 'OR' on meta_query

Essentially, I'm trying to query using a filter for the args being fed into WP_Query() like so: public function filter_wp_query( $args, $template_slug ) { $args['post_type'] = '...
1
vote
0answers
34 views

Add Custom Post Type of specific Custom Taxonomy to regularly blog loop

I want to add a CPT to be shown in the blog. I figured out that I can use the filter hook pre_get_post to get the query object and I can modify it. However just adding another post type to the loop is ...
1
vote
0answers
148 views

Meta Queries - should nesting work after WP 4.1?

I have a rather huge meta_query here and it hangs at execution: browser just won't load the page, it goes on loading ... As far as I know this should work after WP 4.1 (I have it). Also tried ...
1
vote
0answers
345 views

Include data from custom table in WP_Query

I'm building an Estate Agent website. They have a system where they add their available properties and sends them all to the main property portals. As part of this, the system also sends all the ...
1
vote
0answers
150 views

How to make search for posts using get method?

So I am building a WordPress theme for myself to meet my needs, so what I am looking for now is make a search using a get method in PHP. If my URL is something like this : http://www.example.com/...
1
vote
0answers
25 views

Query posts by last comments

How to query posts by lastest comment, like what happens here, if some one comment on a post from the dark ages it will popup to the top.
1
vote
0answers
421 views

SQL query equivalent to WP User Query

I have the following WP user query code: //Get all users sorted by whatever $sorted_users = new WP_User_Query(array( 'orderby' => 'meta_value', 'meta_key' => 'satisfaction_rating', '...
1
vote
0answers
313 views

tax_query OR with empty result returns all posts

I'm running a WP_Query with a tax_query with two tax_query statements with an OR relationship. $tax_query_terms = array( array('taxonomy' => 'post_tag', ...
1
vote
0answers
227 views

WordPress ignoring LIMIT / posts_per_page despite being in wp_query

Using WP query: $myquery = new WP_Query( array( 'posts_per_page' => $instance['count'], 'meta_key' => 'mywp_post_views_count', 'orderby' => 'meta_value_num', 'order' => '...
1
vote
0answers
175 views

Conflict with get_posts and the_content

I have this snippet in my header.php to display a slider: <?php $args = array( 'post_type' => 'post', 'posts_per_page' => 6, 'meta_query' ...
1
vote
0answers
219 views

Multiple Loops on category.php with pagination on last loop

I'm trying to achieve what should be fairly simple but I've hit a brick wall when trying to paginate the last of three loops on the category.php template. I've read just about everything I can find on ...
1
vote
0answers
371 views

WP_Query Order by Specific Post ID First

I'm creating a website where I have a need to show a set of posts from a custom loop but I need to display a specific post first. This post will be dynamically specified in the URI by a $_GET ...