How do I hard code a link to show the standard latest-posts front page? (2 posts)

  1. Anonymous
    Posted 8 years ago #

    How can I hard code a link to show the standard latest-posts front page?

    I've changed my settings so that I have a static front page on my site, this also corresponds to my 'home' button

    <a href="<?php echo get_settings('home'); ?>/" title="Return to the the frontpage">Home<br /><span>Frontpage</span></a>

    However I want the next button on my menu ('news') to behave as the 'home' button normally would if it were set to display my latest posts.

    So what link do I put in here for that?

    <a href=" ?what goes here? " title="Read the latest news">News<br /><span>Read all about it</span></a>

    Or do I need to monkey with one of the php files? I tried looking for what's returning the info in the get_settings('home') but I can't find it and I know little of php. I tried searching for help too but I think the terms are all too common for specific help.

    Thanks in advance

  2. tsguitar
    Posted 8 years ago #

    Well, you can't return the home page because you've turned that into a "static" page, right? So even if you found the link it wouldn't return what you want, is that right?

    Do you want the link for 'news' to lead to what would typically be a latest-posts page? If that's the case, get to your template folder on your site (FTP there), upload a blank PHP file called "news.php" (just copy one of the files already there and rename it), create a Page in WordPress, call it News (don't type anything in it), and tell it to use "news.php" as the template. Go to your Theme Editor and edit "news.php" to something like the following (adjust this for your theme):

    Template Name: News Template
    <?php get_header();
    query_posts('showposts=5'); ?>
      <?php while (have_posts()) : the_post(); ?>
      <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
      <?php endwhile;?>
    <?php get_sidebar();
    get_footer(); ?>

    Then you'll just direct that link on 'news' to the News page and it should display the latest 5 posts.

Topic Closed

This topic has been closed to new replies.

About this Topic