Forums

get_posts from /blog to show on static html page (4 posts)

  1. hcmm
    Member
    Posted 2 years ago #

    I have a static html page that I want to have my recent blog posts titles display in. I've gotten something like this to work before, but the tricky thing about this one is that the static html page is in a different directory than the wordpress installation.

    This is the code I'm trying to use:

    <ul>
    <?php
    global $post;
    $myposts = get_posts('numberposts=5&offset=0');
    foreach($myposts as $post) :
    setup_postdata($post); ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul>

    So is there a way to make this these php snippets somehow link to the wp installation from the static html page?

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    You'll want to look at the examples here:
    Integrating_WordPress_with_Your_Website

  3. hcmm
    Member
    Posted 2 years ago #

    Thank you for responding. I'll take a look.

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

    http://www.corvidworks.com/articles/wordpress-content-on-other-pages
    here's another link

    Thing is, these methods won't work on your standard .html page.....if its called .html

    Have to rename it to .php which usually doesn't affect anything...unless it's index.html, which you may then need to include a bit of code in .htaccess to tell browsers to use your index.php as index.html

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags