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 www.site.com and a blog B with Wordpress structure located in www.site.com/blog. 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
site.com/blog and I wanted site.com's homepage (
index.php) to show, say, 3 Wordpress posts on the "News" section of the page.
So, for site.com I had to add:
<div id="news"> <p>Here you can see our latest News</p> <?php define('WP_USE_THEMES', false); require('blog/wp-blog-header.php'); //Note the folder hierarchy to find wp-blog-header.php ?> <?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; ?> </div>