WordPress.org

Ready to get started?Download WordPress

Forums

Retreive post for static website (5 posts)

  1. menardmam
    Member
    Posted 4 years ago #

    I have 2 website, on two different domain

    One static website that use (html, css, php) and the other one that is wordpress blog with more that 200 post running database

    I like to be able to retreive 4-5 post from the wp blog, and build (on the fly with php) the static website, so the static website will be a sub sample of the large one. All the magic should append in the static website, accessing the blog remotely, How do I do that ?

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

  3. menardmam
    Member
    Posted 4 years ago #

    I have read and use with success this code from the 1st link you gave me

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

    <?php while (have_posts()): the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <?php the_excerpt(); ?>
    <p>">Read more...</p>
    <?php endwhile; ?>

    But I what to get a SPECIFIC POST NUMBER, let say post #1828, i cannot seem to know hos to get it

    I dont know how to integrate that code to make it work

    <?php
    $my_id = 7;
    $post_id_7 = get_post($my_id);
    $title = $post_id_7->post_title;
    ?>

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

    I'm not so familiar with working with query_posts stuff, but I believe what you are trying to accomplish would happen up in the header section of your page...

    query_posts('showposts=1');
    where that bit is.....I guess you just have to flesh it out more with your requirements....I bet the codex could help more than me on this one unfortunately.... (or some smarter member here)

  5. menardmam
    Member
    Posted 4 years ago #

    Here is the comple code that work for me

    <?php require('../mywebsite.com/wp-load.php');

    function getmypost($number)
    {
    query_posts('p='.$number);
    while (have_posts()) : the_post();
    echo '<div class="post">';
    the_title('<h1>', '</h1>');
    the_content();
    echo '</div>';
    endwhile;
    }

Topic Closed

This topic has been closed to new replies.

About this Topic