Forums

Display the latest 10 posts in a static HTML page (8 posts)

  1. webworks
    Member
    Posted 2 years ago #

    Hello, I've been reading about integrating wordpress into a standard HTML website, and need to display the latest 10 posts into a static HTML page.

    I read this

    And, upon searching the forum on this topic, it seems folks are referring to *wordpress* pages instead of *HTML* pages.

    Can someone please help? I'm just not sure what I need from the "loop" codex, nor where I'm to place it :(

    Here is the static HTML page so the source code can be viewed.

    Here is the page renamed with a PHP extention, which I'm assuming must be done, and the errors my code is displaying: errors

    I have this in the header:

    <?php
    require('/home/username/public_html/wp-blog-header.php');
    ?>

    I have this in the body:

    <?php
    require('/home/username/public_html/wp-blog-header.php');
    ?>
    
    <?php
    $posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
    foreach ($posts as $post) : start_wp(); ?>
    <?php the_date(); echo "<br />"; ?>
    <?php the_title(); ?>
    <?php the_excerpt(); ?>
    <?php
    endforeach;
    ?>
  2. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

  3. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    <?php
    require('/home/username/public_html/wp-blog-header.php');
    ?>

    the call to wp-blog-header only goes in the page header, not the body

    you are correct that your page needs to be a .php extension

    Here's my relevant code:
    just before the closing </head> I have

    <?php
    // Include WordPress
    define('WP_USE_THEMES', false);
    require('../wordpress/wp-blog-header.php');
    query_posts('showposts=10');
    ?>

    and in the `<body>' I have:

    <div id="voodooBlog">
          <?php while (have_posts()): the_post(); ?>
            <div class="dateIcon">
            <h5><?php the_time('M'); ?></h5>
            <p><?php the_time('j'); ?></p>
            </div>
            <div class="text">
            <h4><?php the_title(); ?></h4>
            <?php the_excerpt(); ?>
            <p></p>
            <a href="<?php the_permalink(); ?>">Read More...</a>
            </div>
            <br />
            <?php endwhile; ?>
        </div>

    I hope looking at this can help a bit....

  4. webworks
    Member
    Posted 2 years ago #

    Thank you for responding!

    This was a very moronic error on my part - I left out the blog directory. I have them displaying, but I have absolutely no formatting... Can I call the wordpress stylesheet somehow?

    working now

  5. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    I'm not sure about that, maybe with an @import url in the stylesheet? Not my area honestly...

    I just threw some quick styling in my css for my webpage....

  6. webworks
    Member
    Posted 2 years ago #

    Apparently my lame css isn't addressing the blog tags :( I'll have to work on that...

    How can I make it put links to "read more" and then link to the article?

  7. webworks
    Member
    Posted 2 years ago #

    Ah - I see the read more in your code - many thanks!

  8. webworks
    Member
    Posted 2 years ago #

    Does anyone know what could possibly be causing the bizarre bullets upon calling the sidebar with this code into this page

    There is also something strange going on with the search bar.

    <?php get_sidebar('right'); ?>

    I don't see any of these problems in the blog home page itself

    Thanks in advance for your response!
    Heather Mc

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags