drukdude
Member
Posted 2 years ago #
My problem:
I want to have a static front page with some general info about my site. Below that however, I would like to display my latest post or a random post. However, I have no idea how I could include such a dynamic box into a static page.
Can someone tell me what I have to do to get the best of both worlds (static and dynamic)?
Maybe someone has asked this before but I searched forever and did not find an answer that worked for me. If someone could help me I would be extremely thankful.
I'd suggest creating a custom page template for that page and adding:
<?php
$postslist = get_posts('posts_per_page=10&order=ASC&orderby=date');
foreach ($postslist as $post) :
setup_postdata($post);
?>
<div>
<?php the_date(); ?>
<br />
<?php the_title(); ?>
<?php the_excerpt(); ?>
</div>
<?php endforeach; ?>
where you would like your latest post to appear.
http://codex.wordpress.org/Template_Tags/get_posts
drukdude
Member
Posted 2 years ago #
Thanks esmi, this look like what I am looking for. However, I am a total idiot when it comes to code, could you please tell me where exactly I need to add this? My current page.php template looks like this:
[Moderated: Code moderated as per Forum Rules]
Thank you!
drukdude
Member
Posted 2 years ago #
? I violated forum rules to post this code.... well I am sorry. But I still do not know where I have to put this code snippet :-(
go to wordpress.pastebin.ca
post code
come back here with link
drukdude
Member
Posted 2 years ago #
drukdude
Member
Posted 2 years ago #
I managed to get the post displayed, but the title of the post is not a link to the whole post. What do I have to change?