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

73 posts
  • Bought between 50 and 99 items
  • Has been a member for 6-7 years
  • 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

3422 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Community Moderator
  • Bought between 100 and 499 items
  • Referred more than 2000 users
  • Has been a member for 4-5 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+4 more
sevenspark Volunteer 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
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Exclusive Author
  • Envato Studio (Microlancer) Beta Tester
  • United States
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
  • Bought between 50 and 99 items
  • Has been a member for 6-7 years
  • 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

3422 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Community Moderator
  • Bought between 100 and 499 items
  • Referred more than 2000 users
  • Has been a member for 4-5 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+4 more
sevenspark Volunteer 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
  • Bought between 50 and 99 items
  • Has been a member for 6-7 years
  • 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