Is it possible to show the latest wordpress blog post on a page not associated with the blog

73 posts
  • Has been part of the Envato Community for over 6 years
  • Has collected 50+ items on Envato Market
  • Located in United Kingdom
TolputtKeeton says

So what i mean is if i install wordpress in a folder in my website called news then can i pull in the latest post to my index.html in the root of the website?

so i have

index.html news/wordpress blog about us.html etc etc etc

So the blog is separate from the rest of the site but i need to pull the latest post in somehow?

thanks

3451 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $750,000+ on Envato Market
  • Located in United States
  • Helps us moderate the forums
+10 more
sevenspark Moderator says

You’ll find it’s an easier task if you just have the entire website as a WordPress install. WordPress has the capability to create an entire site, not just a blog. If you do it that way, your solution is trivial to implement.

If you have to have the WordPress installation separate, you could use this method – of course, you’d need to use PHP , not just a regular HTML file: http://codex.wordpress.org/Integrating_WordPress_with_Your_Website

Hope that helps :)

1148 posts
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+3 more
fillerspace says

You can include Wordpress code on any arbitrary page by including wp-load.php. Then you just have to create a WP_Query object. So if your blog is in www.domain.com/news, and your home page is www.domain.com/index.php, you would just add the following to index.php:

<?php $path_to_wp = dirname(__FILE__)."/news";
require_once( $path_to_wp.'/wp-load.php' );

do your Wordpress stuff here
?>

Look up http://codex.wordpress.org/Function_Reference/WP_Query for details on creating a query to get your recent posts.

Alternatively, you could use PHP on the index to fetch the RSS feed from Wordpress.

73 posts
  • Has been part of the Envato Community for over 6 years
  • Has collected 50+ items on Envato Market
  • Located in United Kingdom
TolputtKeeton says

Thanks guys your tips helped alot, i have managed to sort this now.

I added this above everything in the homepage…

<?php /* Short and sweet */ define(‘WP_USE_THEMES’, false); require(‘news/wp-blog-header.php’); ?>

and then this where i wanted the post to display…

<?php query_posts('showposts=1'); ?>
            <?php while (have_posts()) : the_post(); ?>
            <div class="blogimg"><?php getImage('1'); ?></div>
            <h4 class="blogtitle"><a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></h4>
            <p class="blogcopy"><?php the_excerpt(); ?></p>
            <a href="<?php the_permalink() ?>" class="readmore">read more</a>
            <?php endwhile;?>
this works great.

thanks again

craig

3451 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $750,000+ on Envato Market
  • Located in United States
  • Helps us moderate the forums
+10 more
sevenspark Moderator says

Great! Glad you got it sorted :)

P.S. I added some pre tags around some of your code to make it more readable

73 posts
  • Has been part of the Envato Community for over 6 years
  • Has collected 50+ items on Envato Market
  • Located in United Kingdom
TolputtKeeton says

Thanks, i wasnt sure how to add code tags but i see it now

code right
by
by
by
by
by
by