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

How do I query all posts of one type across my multisite installation?

I have a multisite wordpress installation with 5 sites, and within each site there are the same 4 custom post type, I want to query the latest 5 posts across all sites where the post_type is gallery ...
1
vote
2answers
5k views

get custom post type by tag

Is it possible to retrieve post entry for a custom post type by tag, I have been trying with the following code, however it just locks me into a infinte loop. <aside class="supporting_images"> ...
1
vote
3answers
2k views

Custom URl parameter

i have Wp blog that need to receive a custom paramter on category page for filter the posts like my rule. For example: http://mysite.com/category/teste?myvar=ABC How can I get the myvar from ...
1
vote
1answer
2k views

Custom Field Query - Meta Value is Array

I'm using a custom field query (or trying to) : $args = array( 'post_type' => 'pf_cookbook', 'meta_query' => array( 'key' => 'pf_cookbook_recipes', ...
1
vote
2answers
6k views

How do I get the title of a category in a custom loop?

I am using the following code to display a list of posts within a category, but I want to display the title in it's own h2 tag above the list. <ul class="subcats-list"> <?php $weightloss = ...
1
vote
2answers
647 views

“Apache HTTP Service has stopped working” with WP Query in WordPress 2.9.2

When my script runs the 4th line below in WP 2.9.2, its causing my web app to throw an "Apache HTTP Service has stopped working" error $cat=get_cat_ID('top-menu'); $catHidden=get_cat_ID('hidden'); ...
1
vote
1answer
190 views

Prevent WordPress from loading comments

I'm displaying the comments for a post my way, using $comm = get_comments() and then passing $comm to wp_list_comments() (this is the reason why). How to disable WordPress from loading comments from ...
0
votes
2answers
135 views

Pagination not working on Custom Page Template

I searched a lot on this but I can't figure out why my code is not working. I published a page with slug "blog" that uses a custom built template "page-blog.php" that I build from editing the ...
0
votes
2answers
44 views

How to order posts in wp_query by a meta_value of the corresponding author

Is it possible to order posts retrieved via WP_Query according to a meta value of the corresponding post author? Use case: I have premium subscribers and basic subscribers. I want the posts of the ...
0
votes
1answer
47 views

relation OR instead of AND - Filtered term ID's in loop

Question not related anymore.. First I tought about the relation OR/ AND for results, but I believe I should work with 'operator' => 'NOT IN'. I would like to query the results that meet multiple ...
0
votes
1answer
36 views

Can't order the query result as given posts id's array

I want to order a query result by the same order as the post id's array given. E.g. I have: $arrayPostsIds = array(30,5,17,10); and I want to get the posts in that order. So after trying this: ...
0
votes
1answer
31 views

Select posts with any post_type from database?

I'm trying to select all rows from the database regardless of post type, however when suppressing post_type WP_Query only gets rows with post_type = "post" is there a way to suppress the post_type ...
0
votes
2answers
29 views

Include both default and Custom Post Type in query modified inside pre_get_posts

I want to include custom post type in the author arhive page. I tried the method discussed in this post: Including post_type = 'wiki' in author archives add_action( 'pre_get_posts', ...
0
votes
2answers
245 views

WP_QUERY Get posts by category and similar name (Like)

I have a small problem with wp_query. I want to get the posts filtered by category and with similar project name (like query), so im trying this code: $args=array( 'post_type' => 'post', ...
0
votes
2answers
474 views

Query multiple meta key values for template

I am using this template: http://demo.undsgn.com/studiofolio/front-page/ I tried to make some modifications because I need the homepage template to display an excerpt beneath each thumbnail. I copied ...
0
votes
1answer
86 views

Retrieve latest post by multiple categories with ID

I have the categories listed below in my product post type. Category Name: Test 1 ID: 82 Category Name: Test 2 ID: 83 Category Name: Test 3 ID: 84 Category Name: Test 4 ID: 85 Now I want to ...
0
votes
1answer
39 views

Custom Taxonomy List links being re-written

I am trying to show a list of terms from my Job Category. I tried the following: function job_listing_taxonomy_list( $taxonomy,$hide ) { $args = array('order'=>'ASC','hide_empty'=>$hide); ...
0
votes
0answers
109 views

How to Display Custom Post Type's Gallery (images ) in Through WP_Query

I am trying to load an Image Slider images from a Custom Post Type image Gallery Feature. For example let say I have an Custom Post Type called banner which I can load images to it's Gallery and I ...
0
votes
1answer
504 views

date_query seems to be ignored by wp_query

I'm altering my main wp_query in a pre_get_posts filter in order to improve my site search capabilities. I've successfully achieved searching in taxonomies, but I fail when it comes to the post date ...
0
votes
1answer
181 views

Can't sort order of wp_query with 2 meta keys

I'm trying to display custom post types by excluding the sold ones but also by displaying them in alphabetical order from the county meta_key. I'm trying to use pre_get_posts but I'm not sure that ...
0
votes
2answers
272 views

Loop with break in the middle

I'm trying to create a gallery type page which shows one post thumbnail from each post category. The trouble is that I want to display the page title and a link to the portfolio page in the middle of ...
0
votes
2answers
121 views

Multiple queries on Home Page - page load/site speed issue

I acquainted a client who designed his own fashion magazine site. My company handed the project to me to make it with WordPress. When I was making the complete template for the site, I found his ...
0
votes
1answer
96 views

how to fire join query with post_meta

I have print sql query that runs within 'posts_where' filter and its like: SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'shop_order' AND post_date >= '2013-08-26' AND ...
0
votes
1answer
727 views

custom post type paging not working past page 3

I have a custom post type called services which has 23 custom posts, i also have a custom taxonomy for all the categories (5 categories). I am trying to create a list of all the custom posts of ...
0
votes
1answer
85 views

Find out if request is for custom post type archive before query runs

I am writing a plugin that is modifying the RSS2 feed for a podcast that uses a custom post type. After the query runs (on action hook template_redirect; See this question for why), I'm checking to ...
0
votes
2answers
2k views

Pagination wont work with search results template [duplicate]

I can't seem to get pagination to work correctly in my search results template. The page links appear, but when i click onto page 2, it gives me a 404 error. Search.php <?php global $wp_query; ...
0
votes
1answer
114 views

Group posts by meta_key

I have a Problem with grouping meta_values. The Query looks for posts with the meta key "company". I want a unique listing of the colors like: blue red yellow array_unique was not successful and also ...
0
votes
1answer
165 views

cloning a WP_Query

I'm working with several nested loops in order to create a statistics table for teams in a league and I'm having trouble getting my original query back. I've read that I should clone the original ...
0
votes
2answers
59 views

Looping through tabular data

I am trying to create a table containing information that is a result of two different loops. The first loops through a list of custom post types to display team names. The other is to provide data ...
0
votes
1answer
1k views

WP_query parameters for date range

I'm using the events manager plugin to create custom posts for events. I do not have a need for a blog, so I modified my theme's index.php file (using a child theme) for its query to retrieve the ...
0
votes
1answer
327 views

querying on custom meta fields and sorting them by custom meta

I have event posts with multiple custom date and time fields. To pull all the events happening this week, I am querying on the different date fields. Here is my code: $today=date("Y-m-d"); $nextweek= ...
0
votes
2answers
170 views

How to output comments number of a post per day?

I have a question about the comment numbers in a post... For now, I can output the total number of a comment inside a post outside the loop. That's cool enough, but I want to get show the comment ...
0
votes
1answer
1k 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
1answer
161 views

How to extract images of post and pages excluding header and logo image in wordpress?

I have tried this code to get all images from media library and i am sucessfully getting the source urls of all the images but now i want to exclude all the unwanted images like logo, header images ...
0
votes
1answer
204 views

Query Problem - Show posts within category 'x' that have a custom field between 'y' and 'z'

I'd like to display all posts within a given price range. For example: When a user inputs 100 and 1000 (in two separate form fields) - my site will display all posts that have a custom field called ...
0
votes
1answer
683 views

Upcoming Event: How do I sort database by custom date field, but ignore past dates?

I am using an events plugin and struggling to get my database query to be perfect. The query is on the event-single.php template. What I need the query to do: Query the "events" custom post type ...
0
votes
1answer
194 views

wp_query and comment_parent - select only posts with top level comments

I have a custom post type of 'films', and I'm creating a number of search filters using wp_query. All are working fine, but I now need to add in an option of exclude results that dont have any top ...
0
votes
2answers
10k views

Show all products on one page with WooCommerce

I have WooCommerce running on this store. Although the default is to show 12 products on a page the client has asked for a "show all" button that will prevent the user having to use pagination to get ...
0
votes
3answers
2k views

WP_Query orderby taxonomy term value (numeric)

I have this query... <?php $press = new WP_Query(array( 'posts_per_page' => -1, 'post_type' => 'individual', 'post_status' => 'private' )); ...
0
votes
1answer
834 views

Get post info inside modal window?

What I'm Trying To Do I have set up a custom post type for 'movies' and below is how I set up the template. Basically, I am trying to get a.thickbox (in the code below) to open a modal window with ...
0
votes
2answers
600 views

What should I use, get_posts or wp_query for less CPU load?

I have a blog and on the main page are 3 blocks of posts. So, I get these posts with "get_post" and I have 3 similar codes on page: global $post; $args = array( ... ); $myposts = get_posts( $args ); ...
0
votes
2answers
2k views

How do I Use Multiple Loops with WP_Query?

Hi I am trying to add post from a certain taxonomy term to a cpt loop. The code below is the code I am using. <?php // Create empty array to store post ids in $excludes = array(); ...
0
votes
1answer
341 views

WP_Query post at custom position

Lets say I have a custom query which based on two custom post types: $wp_query = new WP_Query(array( 'post_type' => array('post-type-1', 'post-type-2'), 'post_status' => ...
0
votes
1answer
978 views

Search another database with wp_query using new wpdb

I currently have a simple wp_query search working on my wordpress site. I now want that same search to look for results in it's own database and another one on same server. I found that I could use ...
0
votes
2answers
2k views

Wp_query order by multiple custom fields?

I am learning WP_query and recently ran into a problem. I need to do a query where i first filter trough one or more custom fields, which works great thanks to meta_query. However, i also need it to ...
0
votes
1answer
1k views

meta_query with array as value

I am writing some PHP which allows users of my site to submit a form and query posts by their post_meta. Everything works fine except for one thing, I used Advanced Custom Fields to create the ...
0
votes
1answer
221 views

get_posts() seemingly ignoring post_type

I am trying to grab posts of post type "leads" (see below for the code I am using) however the query produced (obtained via debug queries) is including the clause 'where post_type in ("leads", ...
0
votes
1answer
169 views

Help with a query not working with custom taxonomy

The query below is always returning the latest "news" post, not the latest "news" post with the taxonomy "sotm". I have verified the details of my custom taxonomy, name is "postCat" attached to post ...
0
votes
1answer
386 views

Alter secondary loop to exclude posts from current page category

The below code is taken from sidebar.php where it outputs random posts from multiple categories and excludes the current post from showing up. This works great but how do I alter this loop to exclude ...
0
votes
1answer
492 views

WP_Query pagination using only numbers instead of /page/1 on URL

I don't get whats happening here. I'm on a child-page template, generating a WP_Query for Custom Post Types on the fly, like this: $notrel = new WP_Query(array( 'post_type' => $type, ...