Skip to content

Instantly share code, notes, and snippets.

@artlung
Created February 11, 2010 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artlung/301974 to your computer and use it in GitHub Desktop.
Save artlung/301974 to your computer and use it in GitHub Desktop.
Most Recent Post with Snippet
<?php
// include trailing slash
$path_to_wordpress_folder = '../wordpress/';
/*
Does someone have a WP plug-in or snippet so that the most recent post on WP
can be seen on a different php page? In this case the homepage.
I'd actually just like a snippet to be seen, not the whole post.
*/
// Learn to use http://codex.wordpress.org/Template_Tags/get_posts
require_once($path_to_wordpress_folder . 'wp-config.php');
$postslist = get_posts('numberposts=1');
foreach ($postslist as $post) :
setup_postdata($post);
?>
<div>
<?php the_date(); ?>
<br />
<?php the_title(); ?>
<br />
<?php the_excerpt(); ?>
</div>
<?php endforeach; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment