I need to retrieve a specific post to display on my websites front page. To avoid hard coding the post ID, I've added a custom property where I add the post ID.
The following code displays the wanted post:
(The code is within the LOOP)
// Get content from specific post (in this case, Åpningstider post))
$openingHoursID = get_post_meta($post->ID, "apningstider", true);
if (!empty($openingHoursID))
{
$openingHoursPost = get_post($openingHoursID);
$openingHours = $openingHoursPost->post_content;
}
else
$openingHours = "Åpningstid ikke angitt";
<div class="openinghours"><?php echo $openingHours; ?></div>
- Is there a better / easier way?
- The output is striped for HTML. How can I maintain HTML?