Skip to content

Instantly share code, notes, and snippets.

@victor-falcon
Created February 21, 2013 15:22
Show Gist options
  • Save victor-falcon/5005423 to your computer and use it in GitHub Desktop.
Save victor-falcon/5005423 to your computer and use it in GitHub Desktop.
Custom Query to get latest blog post on Wordpress
<?php
query_posts('showposts=1');
// set $more to 0 in order to only get the first part of the post
global $more;
$more = 0;
// the Loop
while (have_posts()) : the_post(); ?>
<h4><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'toolbox' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h4>
<?php the_excerpt(); ?>
<?php
endwhile;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment