[wp-hackers] Need help with query_posts and custom post types

Jason Grim jgrim at jgwebdevelopment.com
Thu Apr 28 04:24:13 UTC 2011


This is my first post to wp-hackers.
Trying to use query_posts() to create a custom page through a custom rewrite
with the following arguments:

$args = array (

'post_type' => 'iphone_apps',
'year' => '2011',
'monthnum' => '4',
'day' => '13',
'posts_per_page' => '5',
'cat' => '5'

);

It's creating the following sql query:

> SELECT SQL_CALC_FOUND_ROWS wp_posts.*
> FROM wp_posts
> INNER JOIN wp_term_relationships
> ON (wp_posts.ID = wp_term_relationships.object_id)
> WHERE 1=1
> AND YEAR(wp_posts.post_date)='2011'
> AND MONTH(wp_posts.post_date)='4'
> AND DAYOFMONTH(wp_posts.post_date)='13'
> AND ( wp_term_relationships.term_taxonomy_id IN (5) )
> AND wp_posts.post_type IN ('post', 'articles', 'nav_menu_item',
> 'iphone_apps', 'ipad_apps', 'mac_apps')
> AND (wp_posts.post_status = 'publish' OR wp_posts.post_author = 1 AND
> wp_posts.post_status = 'private')
> GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 5


Seems to be including all post types rather than the one inserted?

Purpose of doing this: the plugin I'm creating for a site is to
run independent of the theme. Trying to avoid the creation of empty pages.

Any advice?

Sincerely,
Jason Grim
jgrim at jgwebdevelopment.com
Owner / Lead Developer
JG Web Development
"a new standard for web design"
(937) 557-1477
www.JGWebDevelopment.com


More information about the wp-hackers mailing list