Skip to content

Instantly share code, notes, and snippets.

@awakekat
Last active August 29, 2015 14:03
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 awakekat/1ceba3709f38c682d8dc to your computer and use it in GitHub Desktop.
Save awakekat/1ceba3709f38c682d8dc to your computer and use it in GitHub Desktop.
Get WP into HTML sites
At the top of the (.PHP not .HTML) page you want to incorporate WP data:
<?php
define(‘WP_USE_THEMES’, false);
require(‘../wordpress/w-blog-header.php’);
?>
Where you want it to show up:
<!— LOOP START —>
<?php
global $post; ~this could be page~
$args = array ( ‘category’ => 2, ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’);
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post);
?>
<div class=“newsstory”>
<div class=“news header”>
<?php the_title(); ?>
</div>
<div class=“newsdate”>
<?php the_date(); ?>
</div>
<div class=“newscontent”>
<?php the_content(); ?>
</div>
</div>
<?php endforeach; ?>
<!-- LOOP END -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment