Forums

static front page with a box for latest post (7 posts)

  1. 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.

  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    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

  3. 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!

  4. 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 :-(

  5. Samuel B
    moderator
    Posted 2 years ago #

    go to wordpress.pastebin.ca
    post code
    come back here with link

  6. drukdude
    Member
    Posted 2 years ago #

  7. 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?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags