Skip to content

Instantly share code, notes, and snippets.

@michaelbrazell
Created September 22, 2014 15:57
Show Gist options
  • Save michaelbrazell/836f529ea4000c2b9cff to your computer and use it in GitHub Desktop.
Save michaelbrazell/836f529ea4000c2b9cff to your computer and use it in GitHub Desktop.
Looping through a post outside of Wordpress
<!-- This is called in the head of this file -->
<?php require('./blog/wp-blog-header.php'); ?>
<!-- way down the page -->
<div class="feature_blog">
<div class="feature_blog_content">
<h4>The Distance Lens Blog</h4>
<?php
$args = array( 'numberposts' => '1', 'category' => '1');
$postslist = get_posts( $args);
foreach ($postslist as $post) :
setup_postdata($post);
?>
<h3><a href="<?php the_permalink(); ?>" style="color:#cc0033"><?php the_title(); ?></a></h3>
<p class="subhead">Posted on <?php the_time(get_option('date_format')) ?></p>
<p><?php the_excerpt(); ?> <a href="<?php the_permalink(); ?>" class="cta">&gt; more</a></p>
<?php endforeach; ?>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment