ansonphong / postworld

Wordpress Theme Development Framework
GNU General Public License v2.0
7 stars 0 forks source link

pw_query() returns empty if no post_type parameter #86

Closed ansonphong closed 8 years ago

ansonphong commented 10 years ago

Hi Haidy, I have been using the pw_query function more, and I noticed that it's returning empty if the post_type parameter is not defined. Are you able to recreate this issue?

hmikhail commented 10 years ago

I tried using this and it values returned:

$args = array(
             'posts_per_page' => '20',
        );

Just as a notice, wp_query sets a default value post_type= 'post' when post_type is not sent, this is the request sent in pw_query for the previous parameters:

SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts left join wp_postworld_post_meta on
 wp_posts.ID = wp_postworld_post_meta.post_id WHERE 1=1 AND wp_posts.post_type = 'post' AND 
(wp_posts.post_status = 'publish' OR wp_posts.post_status = 'future' OR 
wp_posts.post_status = 'draft' OR wp_posts.post_status = 'pending' 
OR wp_posts.post_status = 'private') order by wp_posts.post_date DESC LIMIT 0,20
ansonphong commented 10 years ago

ok this is good to know. in the future I would like to add support for 'default post types' so that if no post type is set, it falls back to a custom array defined in $pw_settings. For example:

$pw_settings['default_pw_query'] = array(
  'post_type' => array( 'feature', 'blog', 'link', 'event', 'announcement' ),
)

Since there is no resources available to do this now, I'll keep this issue open for future implementation.