"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

1
vote
0answers
693 views

Custom WP_Query for WordPress Search Results with meta_query

I am using a custom query to generate my search results. The code I am using works perfectly without the meta_query variables in my arguments array. I am trying to compare multiple custom fields with ...
0
votes
2answers
148 views

How should I approach changing the template & $query as part of a shortcode's execution?

I am working on a project where I need to be able to change the template being used if a given shortcode is used. To complicate things more, the plugin must also be able to rewrite $query if this same ...
0
votes
1answer
73 views

Advise on Templates for Custom Queries

I'm trying to figure out the best way to solve this problem. I have a couple of archive type pages that display content from multiple post types at once. For example, I've overridden the default ...
0
votes
1answer
2k views

WP_Query meta_query by array key

I have a custom post type with its meta in an array. What I need to do is query based on the value of a key in that meta array. $args = array( 'post_type' => 'my-cpt', ...
0
votes
0answers
79 views

Multiple homepage layouts as selected by user from theme options

I am working on a theme which will enable users to select multiple layouts from the theme options panel. What I did so far is to create multiple theme files, depending on each theme, put it in a ...
0
votes
1answer
184 views

How to display WP Query filters?

I'm wondering if there is a way to display current WP Query filters. I wrote a function that is supported to delete all posts and it does but when I'm using WPML and it filters posts by language then ...
0
votes
1answer
5k views

Count posts returned by get_posts in external PHP script

I'm using WP from an external PHP script by including the wp-load.php file. All functions and everything works as expected so far, except one thing: I can't get the $wp_query->found_posts to work ...
0
votes
1answer
625 views

WP_Query of a custom post type isn't working

I am trying to WP_Query a custom post type. I would like to display the post_title s in a list. Here is my code, it doesn't seem to work: <?php add_action( 'init', 'custom_faq_type_mp' ); function ...
1
vote
2answers
2k views

Retrieving list of a custom post type in a widget without using WP_Query?

I'm using the following widget to retrieve a list of the custom post type jobs: class FeaturedJobsWidget extends WP_Widget { function FeaturedJobsWidget() { $widget_ops = array('classname' ...
0
votes
0answers
85 views

Creating Advanced Search with text & Dropdowns [duplicate]

I am working to develop an advanced search option. Where there will be fields: Text input Field (Post Title) Dropdown (it will be a taxonomy) Dropdown (it will be a taxonomy) Basically I need ...
2
votes
1answer
629 views

Perform query with meta_value date

I am trying to perform a query on a custom-type post using the value of a custom field. This field contains a string date: dd.mm.yyyy. The post type name is 'event' The custom field name is ...
0
votes
1answer
1k 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
5k 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
418 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
539 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
121 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
27 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
268 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
386 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
560 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
904 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
353 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 ...
3
votes
2answers
921 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
146 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
136 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
107 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
1k 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
89 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
154 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
451 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
237 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
369 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
113 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
588 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
96 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
474 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
141 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
311 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
3k 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
168 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
590 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
313 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 = ...