Luiz Cruz Luiz Cruz - 17 days ago 4x
HTML Question

Display Wordpress posts in other webpage

I'm having a bit of trouble trying to understand the Wordpress functions to display posts from a Wordpress blog to a website.

Basically I have a website and a blog B with Wordpress structure located in I want to learn to display B's recent posts in A.

I know I'll have to use PHP to call B's posts and display them in A as HTML elements. I messed around with the PHP functions but wasn't able to execute a solution correctly.

Can you help me please?


Thanks for all the help.

As I said, I installed Wordpress on and I wanted's homepage (index.php) to show, say, 3 Wordpress posts on the "News" section of the page.

So, for I had to add:

<div id="news">
<p>Here you can see our latest News</p>
define('WP_USE_THEMES', false);
require('blog/wp-blog-header.php'); //Note the folder hierarchy to find wp-blog-header.php
$my_query = new WP_Query('showposts=3'); //"3" being the number of posts to be shown
while ($my_query->have_posts()): $my_query->the_post();
<h3><?php the_title() ?></h3> //This makes the post title show inside a h3 tag
<p><?php the_excerpt() ?></p> //This makes the post excerpt show inside a p tag
<?php endwhile;