Get Custom post with ID

You simply don’t need to specify a post_type when calling get_post(). The ID for any sort of post is unique among the whole DB-posts table. So if you’re calling a post with ID = 17

$id = 17;
$post = get_post( $id );

then you’ll simply get this single post.

Note, according the Codex, when using get_post

You must pass a variable containing an integer (e.g. $id). A literal integer (e.g. get_post(7)) will cause a fatal error (Only variables can be passed for reference or Cannot pass parameter 1 by reference).

Leave a Comment