1
votes

I have installed wordpress on my site located at www.example.com/blog. on www.example.com I'd like to retrieve the top 5 latest blog posts and display date, url and blog title. Is this possible?

This means I want to get the blog posts from outside the wordpress installation using php and do a loop.

4
You are not telling us what you want to do - where you want to do it from.Emil
@Emil, are you serious? others understood the question...Shawn Mclean
I see nothing wrong with the question.Pekka
@Shawn & @Pekka: In the first revision, he said nothing about how he wanted it done or from where, other than "I have a blog. I want to see the latest 5 posts with date, url and title.", so I thought that was a bit to little information.Emil

4 Answers

7
votes
<?php
    $loop = new WP_Query('showposts=5&orderby=ID&order=DESC');
    if($loop->have_posts()): while($loop->have_posts()): $loop->the_post();
?>
    <div class="post" id="post-<?php the_ID(); ?>">
        <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
        <span class="post-meta">
            <?php the_time('F jS, Y'); ?> by <?php the_author_posts_link(); ?>
        </span>
    </div>
<?php endwhile; else: ?>
    No recent posts yet!
<?php endif; ?>

See: WordPress Loop, query_posts(), WP_Query(). There are also plugins to get recent posts.

1
votes

Yes you can use the RSS feed of your blog. Its a standard wordpress feature. Use a javascript (or some server side) rss client to fetch the top 5 entries from RSS feed and show it on your homepage.One such script is http://p3k.org/rss/

1
votes

Use WP_Query like sugested by Sepehr and after you include wp-blog-header.php add this:

header("HTTP/1.1 200 OK");

This overrides WP's security check.

0
votes

Yes you can.

in wordpress you must use blog in blog plugin. if it's use you set tempalte form your design and put the shortcode like "[blog_in_blog category_slug='my-category-slug' num=5]" in your cms page or php file and you display first 5 post with date any where in your site. you must create categories and put in short code.

blog in blog :- http://wordpress.org/plugins/blog-in-blog/