• How can I integrate the most recent wordpress blog entry into php page that uses php includes?

    Here is my page:
    https://halfpricewinenight.com/home.php
    I would like to have the blog info populate the columns in the middle (wine of the week) and (blog) for approximately 12 lines and then be able to click to read more. Is this possible?

    Thanks!!!

Viewing 1 replies (of 1 total)
  • 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 1 replies (of 1 total)
  • The topic ‘Integrate wordpress blog entry into php page’ is closed to new replies.