Adding WordPress Content to an HTML Page

I know there are a lot of posts out there about this, and at least one from wordpress.org, but I thought I’d share what I learned from reviewing all these posts and, ultimately, my friend John Branigan. Also, I may be able to write this in a less technical way than the other posts, because I have no idea how to use the necessary lingo.

  1. Install WordPress with your Internet host.
  2. Save your HTML index page with a .php extension. It seemed counterintuitive to me, but that is what finally got my WordPress posts to populate on my website.
  3. Add the following header, provided by wordpress.org, between <head> and </head> tags:
    ?php
    /* Short and sweet */
    define('WP_USE_THEMES', false);
    require('./wp/wp-blog-header.php');
    ?>
  4. Then John gave me the following script to place in the body of the page, where you want the blog post to populate on the page:
    <?php query_posts('showposts=-1');
    if (have_posts()) :
    while (have_posts()) :
    the_post();
    ?>
    <h2><?php the_title(); ?></h2>
    <?php the_content(); ?>
    <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small><br><br><br>
    <?php
    endwhile;
    endif;
    ?>

With those three steps, I was able to make it happen. I am going to, or already have, added some more php code to display other parts of the WordPress blog such as the publication time and date. My goal is to display the comment section, but some of the reading I’ve done makes it look like that will be difficult. Good luck to us both!

One thought on “Adding WordPress Content to an HTML Page

Leave a Reply

Your email address will not be published.