The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Retreive post for static website (5 posts)

  1. menardmam
    Posted 6 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
    Posted 6 years ago #

  3. menardmam
    Posted 6 years ago #

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

    // Include WordPress
    define('WP_USE_THEMES', false);

    <?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

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

  4. Rev. Voodoo
    Posted 6 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...

    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
    Posted 6 years ago #

    Here is the comple code that work for me

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

    function getmypost($number)
    while (have_posts()) : the_post();
    echo '<div class="post">';
    the_title('<h1>', '</h1>');
    echo '</div>';

Topic Closed

This topic has been closed to new replies.

About this Topic