Custom SELECT Query not returning the_title and the_permalink
Because $pageposts is an array of post IDs, but you need to pass a post object to setup_postdata – pull the objects instead: SELECT $wpdb->posts.* [rest of query] Note that, since you’re not paginating, you don’t need SQL_CALC_FOUND_ROWS