On my index page I have a section that displays "the latest news" which is simply the content taken from a specific post. I don't need a loop because I only want to display information from 1 particular post whose contents gets edited when needed. This is my code to get what I want:
<?php if (have_posts()) {
$mypost = get_post(1, ARRAY_A); ?> /*Here I choose the post with ID 1*/
<h2><?php echo $mypost['post_title']; ?></h2>
<p><em><?php echo $mypost['post_date']; ?></em></p>
<p><?php echo $mypost['post_content']; ?></p>
<?php } else { ?>
<h2><?php echo "There are no posts.";} ?>
I am just wondering if there is a better way to do this?
Also, I would like to format the time stamp neatly, like what is done in the loop, but I am thinking that I would have to write my own function for that. Is there a function that does that already that works outside of the loop?