Skip to content

Instantly share code, notes, and snippets.

@nashvillegeek
Created April 22, 2013 18:14
Show Gist options
  • Save nashvillegeek/5437215 to your computer and use it in GitHub Desktop.
Save nashvillegeek/5437215 to your computer and use it in GitHub Desktop.
Wordpress: Recent Posts Script
<snippet>
<content><![CDATA[
<div class="recentPost widget">
<h2>Recent Posts:</h2>
<?php
global \$post;
\$args = array( 'numberposts' => ${1:5},'category' => ${2:'uncategorized'} );
\$myposts = get_posts( \$args );
foreach( \$myposts as \$post ) : setup_postdata(\$post); ?>
<div class="recentPostItem">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php the_excerpt(); ?>
</div><!-- end .recentPostItem -->
<?php endforeach; wp_reset_query(); ?>
</div><!-- end .homeRecentPost-->
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>wp-recent-post</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment