modify default query for custom_post in admin (list, columns))
-
Hi,
I’m trieing to extend the deafault query with a left join on an additional table.
function accommodation_join( $join ) { global $wp_query, $wpdb; if( $_GET['post_type'] == 'accommodation' ) { $join .= " LEFT JOIN accommodation ON " . $wpdb->posts . ".ID = 'accommodation.__idPost' "; } return $join; } add_filter('posts_join', 'accommodation_join' );This seems to work but this returns:
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts LEFT JOIN accommodation ON wp_posts.ID = 'accommodation.__idPost' WHERE 1=1 AND wp_posts.post_type = 'accommodation' 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, 20It askes for the fields in wp_posts only
wp_posts.*but I need information from the accommodation table also.Is there any way to achieve this?
I hope somebody can help!
The topic ‘modify default query for custom_post in admin (list, columns))’ is closed to new replies.