"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
2k views

Custom query with category exclusion and post-meta “whitelist”

I have two widgets, one shows News while the other shows everything except News (We'll call the second one Blog). The blog portion is currently working correctly. The News posts are either ...
0
votes
1answer
2k views

Filtering a WP_Query meta_query by numeric values isn't working

That was a very dense title. I have a custom post type "event" which has a Date/Time picker field "event_date" thanks to the Advanced Custom Fields plugin. This Date/Time picker saves a UNIX ...
1
vote
1answer
6k views

Get Posts in a Custom Post Type category

I have trouble in getting post in a custom post type category. I have code below but it doesnt work well. It still get posts in another category. <?php $query= null; $paged = ...
0
votes
1answer
444 views

WP_Query order custom post type with certain meta key value by post modified date

I have this query to show custom post type "property", and it works really well but the "orderby" statement, that is completely ignored... $args = array( 'post_type' => CUSTOM_POST_TYPE1, ...
0
votes
1answer
594 views

Delete data from custom table when deleting a post

I want to delete post id form my custom table, when deleting a post. I have tried this way, nothing happened. Please help. add_action('delete_post', 'delete_data'); function delete_data($post_id) { ...
1
vote
1answer
147 views

Reverse chronology of post listing

I"m working on modifying a theme that is based on 2010. I want to make the posts on this blog display earliest to oldest, but I don't see how to do this in the theme: I understand I need to add . ...
2
votes
1answer
2k views

WP_query : meta_key with custom rule for specific value

I'm a bit stuck with a WP_Query code. Here it is : $args = array( 'post_type' => 'post', 'meta_query'=> array( 'key' => 'karma', 'compare' => '>=', ...
1
vote
1answer
28 views

If Query In Sidebar

I'm trying to create a query that IF there is a value in the 'FeaturedQuote' custom field, then this shows <h3 class="featuredquote"><blockquote><span ...
1
vote
1answer
288 views

Mysql query and order meta value

I made a mysql query to WordPress like this: $querystr = " SELECT $wpdb->posts.* FROM $wpdb->posts, $wpdb->postmeta WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id AND ...
0
votes
3answers
48 views

Is there a way to make this kind of loop shorter and nicer?

Here is my loop code, i want to call different page templates for different pages. Please notice that this is a one-page-layout. <?php $args = array( 'post_type' => 'page' );?> <!-- get ...
-5
votes
2answers
2k views

How can I display sticky posts at first in wp_query?

I'm looking for a long time, but I could not find a solution. I'm not a coder. Please help me. Here is my wp_query code; $my_query = new WP_Query('category_name=animals&showposts=10'); while ...
0
votes
1answer
407 views

Insert data in custom table during new post creation

I want to in insert data in my custom db table when creating a post. Suppose there are three categories (php, wordpress & jquery). When i create a post in wordpress, i want to insert post id and ...
0
votes
1answer
609 views

How does Show Posts based on a keyword search work in WP_Query

I am wondering how the search go through by defining 's' parameter in WP_Query. For example if I have a post assigned to "East" term in taxonomy "Direction", the post didn't mention any "East" or ...
2
votes
1answer
971 views

Combine two taxonomies in a hierarchical tree

For example, I have WooCommerce products that have taxonomies: brand (e.g. Converse, adidas, D&G) (taxonomy id: product_brand) category (e.g. Boots, Sneakers, Sandals, Heels) (taxonomy id: ...
0
votes
0answers
387 views

Query recent posts by author

I'm fairly new to wordpress but trying to get recent posts by a specific author. The following code displays only most recent bog posts. I am using a custom field to get the author ID. EDIT by ...
4
votes
2answers
1k views

How to prevent execution of default query, while preserving ability to use WP_Query in template?

PROBLEM: I'am trying to prevent execution of default WordPress query for custom category template. I have found a possible solution, but looks like it preventing execution of all post queries: ...
1
vote
1answer
159 views

WP_Query returns more results than expected

I've written a query that is supposed to return all attachments called "no-image" (is part of a function that handle images fallback when there isn't a featured image), the if I get some result, the ...
0
votes
1answer
1k views

wp Query Posts to display in Nivo Slider

i have coded a slider into my wordpress theme to use query posts to display the thumbnail and the content however it appears that its displaying the whole posts? and not just the one relating to the ...
1
vote
2answers
137 views

Trying to find a way to query post like normal search would do. within search.php page

I have a costume search in a site i am making. When a user search a certain term, i want to display category list with a count of how many posts are found with in that category. I thought of a way ...
2
votes
1answer
108 views

Filter WordPress posts by between parameter

How to filter WordPress posts by a taxonomy and between parameter? Consider a mobile website with "memory size" taxonomy, I need to show posts that have more than 256 mb memory and less than 768 mb. ...
0
votes
1answer
2k views

Display products from specific category in shop page

I know many people asked for this question but I didn't find a proper way to do it. How to add a simple meta_query (product_cat) before the execution of the shop page's query. Maybe by using a filter ...
2
votes
1answer
1k views

add_filter and remove_filter added before and after wp_query

I have just started with WordPress Development, and found following block of code online (in some tutorial) function filter_where( $where = '' ) { // posts in the last 30 days $where .= " AND ...
0
votes
1answer
92 views

Display posts from a category

I am trying to display a bunch of posts from a single category on the category page, using multiple loops. <div id="featured-content" class="clearfix"> <? // assign the variable as current ...
0
votes
1answer
169 views

next_posts_link returns same content of 1st page

Pagination seems to work fine... I have 21 posts... and it will go to 3 pages... however... every page shows 10 posts and the same content as the first page.... <?php $temp = $wp_query; $wp_query= ...
0
votes
2answers
527 views

Custom search: Search posts but display parent page in results

I'm using Wordpress 3.5.1 with a modified twentytwelve theme. My main site structure is based on the Smooth Slider plugin (jQuery Cycle). I have Pages that contain only a shortcode (for example, ...
0
votes
1answer
250 views

Highlight post in sidebar on single page

When you have a menu for say pages, it's easy to highlight your current page, since WP puts a class on it. But what I have is a sidebar with the 20 latest posts in a loop and a separate main content ...
2
votes
1answer
382 views

Can you order posts from wp_query by two custom meta fields?

I'm working on a site that lists events. Right now this query lists events by date: $args = array( 'post_type' => 'espresso_event', 'post_status' => ...
0
votes
1answer
88 views

404 on Pages for Custom Post Type & Query_Posts

It took me quite a while to find a good solution for ordering a custom post type by two custom meta keys. When I finally got it working, I found out the pagination no longer works. I've tried dozens ...
0
votes
0answers
120 views

Custom Post Query Combined with Conditional Tags

Is it possible to combine displaying a list of custom post types on a single page depending on conditional tags? Below is what I have so far, basically if there are 4 posts or less show the posts, if ...
1
vote
1answer
713 views

creating wp query with posts with specific category

Im running a specific wp_query to show the thumbnails in a slider of a specific category. <?php $the_query = new WP_Query ('showposts=2', 'category_name=Events'); ?> This doesnt appear to be ...
0
votes
1answer
26 views

Finding a post's slug

I'm using wp_query() to get custom posts from the database. I want to list these out as links to the entries, so I'm thinking I could use the slugs. Sadly these don't seem to be included in the ...
0
votes
1answer
98 views

WP_Query in a shortcode

I am trying to put several queries in a shortcode so that I can call them in a page instead of using custom templates. I got my query going but I only see some of the content on the page. The image ...
0
votes
1answer
536 views

How to use WP_Query in a CPT achive page?

I can't get WP_Query to work in my custom-post-type archive page. Can someone please tell me what I'm doing wrong? I would appreciate any help. Here's the code in archive-bulletin.php: <?php ...
0
votes
1answer
147 views

Cant' Display Custom Post Type Title Base on Tax Terms

Trying to list all Custom Post Type titles based on filtered Custom Taxonomy Terms I am getting the list of all post titles instead of getting the list of Queried post. Here is the code I am using: ...
0
votes
1answer
336 views

Problem with is_tax in WP_Query loop

The code below is the 2nd of 4 loops in "page-balls.php". Everything else is working correctly. I'm trying to display a tennis ball graphic if the post being retrieved has a the term "tennis-ball" ...
7
votes
1answer
4k views

Multiple relationship for multiple tax_query in WP_Query

I want to use the WP_Query class to filter some of my posts. The problem I facing now is handling the taxonomy query. Normally, the wp_query only handle one relationship for tax_query (either AND or ...
0
votes
1answer
176 views

WordPress | WP_Query does not return anything with s=a

I have the following code: $data = new WP_Query('s=a'); and the print_r returns the following data: WP_Query Object ( [query_vars] => Array ( [s] => a ...
1
vote
2answers
632 views

Next/Prev posts on same page

Hello WordPress Users, I'm stuck with a problem building my wordpress website and I can't figure out what to do about it. Currently I'm showing 2 posts form the category 'News' at the page 'News'. ...
0
votes
1answer
351 views

WP Paginate not working properly

Im creating a WP for a custom type post in a page template: <? global $paged; global $notquery; $temp = $notquery; $notquery = ...
1
vote
1answer
38 views

Query “Category A” + 1 post from “Category B” - how?

It's pretty easy to query posts from one category but what if I need also one single post from another category? $query = new WP_Query( 'cat=4' ); I'm looking for something like this: $query = new ...
0
votes
1answer
129 views

WP_Query calls all posts?

I have this code that picks a random testimonial post. <?php $quote_args = array( 'post_type' => 'post', 'category' => 'quote', 'orderby' ...
2
votes
1answer
696 views

Gravity Forms field entries into wp_query loop [closed]

I have a simple function that filters the page content when form (ID 18) is submitted. It simply displays the entry of field (ID 13)... add_action("gform_after_submission_18", "set_post_content", 10, ...
0
votes
2answers
3k views

How to apply filter inside a single wp_query?

I've got a special query on my homepage that returns posts from a custom taxonomy. I'm trying to apply this filter for it. add_filter( 'post_limits', 'my_post_limits' ); function my_post_limits( ...
0
votes
1answer
104 views

What is wrong with this wp_query?

I need to query posts by two meta fields and the wo_query I'm doing it with is returning nothing. Obviously, it's broken. Can somebody tell me what I'm doing wrong? $args = array( ...
1
vote
4answers
3k views

Get count of custom post type created by current user

I'm trying to get the count of published posts in a custom post type for the current user (to display on a profile page). I found this here on the forums: <?php global $wp_query; $curauth = ...
0
votes
1answer
115 views

Exclude an array

I'm moving edit post dashboard to front end. So here is a case, I have to queries, one for product attachments and other for ALL. Now, I want to exclude product attachments from ALL attachments query ...
0
votes
1answer
79 views

Randomly pick one testimonial post

I want to show one randomly picked testimonial on a page. Each testimonial is a post with a category of 'quote'. Each post has a custom field named 'who' with a name. I'm trying to use this code. ...
0
votes
1answer
188 views

WP_query exclude a category unless it has more then one catagory

I have this category exclude_cat with id 39 I want to exclude it from the home. So I use for WP_Query args like this: $args = array ( 'category__not_in' => array( 39 ), //exclude ID ); Works. ...
1
vote
0answers
71 views

How to output topics and replies in bbpress as table?

I need to output the bbpress topic and reply loop in a table format. I'm having trouble finding how one might do this Are there any suggestions on how one might do this? Can this be done using ...
0
votes
1answer
496 views

wp_dropdown_pages with tax_query clause

I'm display a dropdown list of custom post types in wordpress. This first block of code uses WP_Query $houseQuery = new WP_Query( array( 'post_type' => 'house', 'order' ...