Forums

Displaying posts on a static page (4 posts)

  1. orbitrod
    Member
    Posted 3 years ago #

    How can I display the latest posts from my blog onto a static web page?

  2. Mark
    Member
    Posted 3 years ago #

    Static Web page where? Inside WordPress - created by the page editor? Or just some regular HTML file?

  3. Mark
    Member
    Posted 3 years ago #

    Here are the basics for PHP code that you can put in another PHP file (your static HTML page) - you'll have to adjust this to fit into your own site (directory path, etc):

    <?php
    include('wp-config.php'); // include the basic WP startup stuff
    query_posts('showposts=10');  // get the last 10 posts
    while (have_posts()) { // got any posts?
    // start writing the HTML output for each post here....
        the_post(); // stuff the required parameters
        // write the title
        echo '<h3><a href="'.the_permalink().'">the_title().'</a></h3>';
        // write the content
        echo the_content();
    // etc etc etc
    }
    ?>
  4. orbitrod
    Member
    Posted 3 years ago #

    A regular HTML file, I will try your code and let you know how it goes.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.