Title: Post id include not working.
Last modified: August 30, 2016

---

# Post id include not working.

 *  Resolved [stovesy](https://wordpress.org/support/users/stovesy/)
 * (@stovesy)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/post-id-include-not-working/)
 * Have I got this wrong…
 * I can include a page by passing the ID, but not a post…
    So changing this gets
   it to work – a hack; I’m sure there’s a more elegant way of doing it
 *     ```
       //	query_posts(array('page_id' => $id));
   
       	$post_type = $wpdb->get_var("SELECT post_type FROM {$wpdb->posts} WHERE ID = '{$id}'");
       	if ($post_type == 'page')
       		query_posts(array('page_id' => $id));
       	else if ($post_type = 'post')
       		query_posts(array('p' => $id));
       	else
       		return $r;
   
       	the_post();
       ```
   
 * [https://wordpress.org/plugins/include/](https://wordpress.org/plugins/include/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Michael Flynn](https://wordpress.org/support/users/mflynn/)
 * (@mflynn)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/post-id-include-not-working/#post-6263601)
 * When I wrote this, page_id worked for posts. Thank you for letting me know that
   that no longer works for posts, and I will update the plugin to utilize this 
   within the next hour. I will make sure to credit you in the change log.

Viewing 1 replies (of 1 total)

The topic ‘Post id include not working.’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/include.svg)
 * [Include](https://wordpress.org/plugins/include/)
 * [Support Threads](https://wordpress.org/support/plugin/include/)
 * [Active Topics](https://wordpress.org/support/plugin/include/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/include/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/include/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Michael Flynn](https://wordpress.org/support/users/mflynn/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/post-id-include-not-working/#post-6263601)
 * Status: resolved