Support » Fixing WordPress » Pulling a post to display on my homepage

  • Is there a snippet of PHP code that I could include within my index.html (homepage) that would pull the most recent post from WordPress (my blog) and display it on the homepage? I guess though if the page contained PHP code I’d have to rename it index.php of course…

Viewing 8 replies - 1 through 8 (of 8 total)
  • Sort of…The second link (which ulitmately links back to one of the support pages here at talks about how to pull one category to display on the index page– BUT, the post doesn’t make clear which index page it’s talking about– index.php that is wp blog homepage on my site, or my site’s inex.html file. I know that WP has an index.php file.
    I moved wordpress to the “blog” directory on my webserver. So I have an index.html file in the main dir that is my site’s homepage (not the blog homepage), with a link to the blog index page (or, “../blog/index.php”).
    What I want to do it display the most recent post (which ever category; doesn’t matter to me right now) on my site’s homepage; it will also be displayed, of course, on the WP index (index.php, within the blog dir).
    And I know that if there is some PHP code I can include in my site’s main index, then it will become a “.php” file.
    Is that clear?


    Is there no way to easily pull a post from the db and display it on another page?

    Mark (podz)


    Support Maven

    You’ll need to use an RSS reader to read the feed from the blog, then display it – I’m not sure if there is another way, but there might be….



    First: your site is OK in FF, slightly messed up in IE 5.5
    To the question. Yes, there are many ways to pull a post and display it on another page. Actually you can do that (I mean displaying them elsewhere) with almost all template tags > see Wiki.
    The only thing is you have to make the “other” page a php file and to add the first lines from your blog-index page.
    I have the WP calendar in a totally different directory (actually subdomain) displayed…


    Thanks; I looked at the wiki on template tags…
    I sort of get it. The tags say that they must be used within the “loop”…so how would i use that on my homepage?
    While I don’t know PHP well, I do know how code is structured, know about loops, etc…


    im having the same problem.. im using the 1.3alpha 4
    Ive made a “Page” in the manager and have set my permalinks to
    my page link is like so:
    my wordpress folder is in the features directory and the page I want to display this “page” on is in the features directory as well in a folder “01”. On the index.php of that folder Ive put this line of code at the top:
    /* Don't remove this line. */
    $blog = 1;
    if (!isset($p)) {
    $p = "brandon-rike-interview";

    and in the div I want the post displayed I have this code:
    <div id="contentfeat">
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php the_date('','<h2 class="dateicon">','</h2>'); ?>
    <div class="post">
    <h3 class="storytitle" id="post-<?php the_ID(); ?>">" rel="bookmark"><?php the_title(); ?></h3>
    <div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> | <img src="graphics/author.png" width="11" height="10" border="0" alt="" /> <?php the_author_firstname() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div><!-- close meta -->
    <div class="storycontent">
    <?php the_content(__('(more...)')); ?>
    </div><!-- close storycontent -->
    <div class="feedback">
    <?php wp_link_pages(); ?>
    <?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?>
    </div><!-- close feedback -->
    <?php trackback_rdf(); ?>
    </div><!-- close post -->
    <?php comments_template(); // Get wp-comments.php template ?>
    <?php endwhile; else: ?>
    <?php _e('Sorry, no posts matched your criteria.'); ?>
    <?php endif; ?>
    <?php posts_nav_link(' — ', __('&laquo; Previous Page'), __('Next Page &raquo;')); ?>
    </div><!-- close contentfeat -->

    and when I view the page I get the “Sorry, no posts matched your criteria.”
    Do I have alot of things out of wack here? is this bit not getting my post name?
    if (!isset($p)) {
    $p = "brandon-rike-interview";

    If I can get this solved it will be my last obstacle in getting a new site up as I need to use this method on a lot of pages….


    ~bump 😉

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Pulling a post to display on my homepage’ is closed to new replies.