On home page I want to display a post (by ID – given by admin as theme option) with its title, excerpt & featured image. I have tried it with a function get_post, but it doesn’t seem to work. At first it gives Fatal Error, but then after figuring out that it needs variable as an ID, its solved. But still I’m unable to get the information I need there on home page (front-page.php template).
Referring to this: http://codex.wordpress.org/Function_Reference/get_post
I have this should display a title of the post with ID = 7. But it doesn’t can anybody figure out how to use this for my purpose? I also need featured-image & excerpt.
<?php $my_id = 7; $post_id_7 = get_post($my_id, ARRAY_A); $title = $post_id_7['post_title']; ?>
- The topic ‘Unable to use get_post to display post by ID’ is closed to new replies.