Title: bellyup's Replies | WordPress.org

---

# bellyup

  [  ](https://wordpress.org/support/users/bellyup/)

 *   [Profile](https://wordpress.org/support/users/bellyup/)
 *   [Topics Started](https://wordpress.org/support/users/bellyup/topics/)
 *   [Replies Created](https://wordpress.org/support/users/bellyup/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/bellyup/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/bellyup/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/bellyup/engagements/)
 *   [Favorites](https://wordpress.org/support/users/bellyup/favorites/)

 Search replies:

## Forum Replies Created

Viewing 1 replies (of 1 total)

 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Blog posts on a page outside WordPress](https://wordpress.org/support/topic/blog-posts-on-a-page-outside-wordpress/)
 *  [bellyup](https://wordpress.org/support/users/bellyup/)
 * (@bellyup)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/blog-posts-on-a-page-outside-wordpress/#post-795032)
 * An alternative for those not wanting to use WP templates at all. This is simpler
   although you have to be careful what is being selected is what you want. The 
   example assumes you have PEAR:DB or MDB2 installed but it’s simple to convert
   to use ‘normal’ PHP mySQL built in commands
 *     ```
       /*
        * getLatestBlogEntries
        * Connects to the WP blog DB and retrieve latest 8 postings
        * formatting them in HTML
        *
        */
       function getLatestBlogEntries() {
   
       	$blogSQL = "SELECT * FROM wp_posts
       					WHERE post_type = 'post' AND 	post_status = 'publish' ORDER BY post_date DESC LIMIT 8";
   
               // Connect to db and perform query
       	$dbBlog = DB::connect(BLOG_DB_DSN, true);
       	$resBlog =& $dbBlog->query($blogSQL);
   
               // loop through result set building links to blog posts
       	$html = '<ul>';
       	while($resBlog->fetchInto($blogEntry, DB_FETCHMODE_OBJECT)) {
       	$html .= '<li><a>ID.'" title="'.stripslashes($blogEntry->post_title).'">'.$blogEntry->post_title."</a></li>\n";
       	}
       	$html .= "</ul>\n\n";
   
               // return resulting unordered list of latest blog entry links
       	return $html;
   
       }
       ?>
       ```
   

Viewing 1 replies (of 1 total)