Support » Fixing WordPress » listing post titles and links on home page

  • Resolved loco2402

    (@loco2402)


    Hello,

    Still kinda new to WP…

    I want to be able to list recent blog posts by just the title in a section of my home page, much like Texas Monthly does (see BurkaBlog and Eat My Words in lower left of page). My home page is outside the WP directory.

    Would like to know which parts of the PHP to grab and place in the home page to get this to work, if that is possible.

    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • esmi

    (@esmi)

    Forum Moderator

    Have you tried using the Recent Posts widget in Appearance -> Widgets?

    I have not, as my home page is the root index.html, outside the WP directory and static (but easily converted to PHP). I am unsure what code I need to add to this page to just pull the last 2 – 3 post titles.

    esmi

    (@esmi)

    Forum Moderator

    Ah! In that case have a look at integrating WordPress with your web site.

    I found the solution, and frankly didn’t think it would be this easy. I have looked at the page esmi referenced numerous time, but in my inexperience, never thought to try the code samples at this location on that page. It does exactly what I have been looking for for over a week. : P

    I put

    <?php
    require('/the/path/to/your/wp-blog-header.php');
    ?>

    at the top of my home page, and

    <?php query_posts('showposts=3'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a><br />
    <?php endwhile;?>

    in the DIV I wanted it to show up. And it worked.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘listing post titles and links on home page’ is closed to new replies.