Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hey! Great code dbmartin, one question…how can I add the excerpt of the post to be pulled in just below the post title?

    Thanks ??

    Thread Starter leighring

    (@leighring)

    Here is teh php code I’m using to pull in the blog content. It works well, showing the title and “read post” button, but does not show the blog content (or full body of the blog). Any ideas:

    <?php
    /* Example #1: php to pull and publish wordpress 2 post data
    on an external page NO CACHE.
    https://www.roccanet.com
    */

    define(‘WP_USE_THEMES’, false);
    require(‘blog/wp-blog-header.php’);

    $how_many=100; //How many posts do you want to show
    require_once(“blog/wp-config.php”);
    // Change this for your path to wp-config.php file

    $news=$wpdb->get_results(“SELECT ID,post_title,
    post_excerpt FROM $wpdb->posts
    WHERE post_status= \”publish\”
    ORDER BY ‘ID’ DESC LIMIT “.$how_many);
    foreach($news as $np){

    //NOTE: get other post data by selecting different
    //data in the posts table…

    $permalink=get_permalink($np->ID);

    $html= “<a href=\””. $permalink .
    “\”>$np->post_title

    $np->post_excerpt <a href=\”” . $permalink .
    “\”>read post

    \n”;

    //NOTE: you can easily alter the HTML above to suit

    echo $html;

    }
    ?>

Viewing 2 replies - 1 through 2 (of 2 total)