Skip to content

Instantly share code, notes, and snippets.

@kylelarkin
Last active December 15, 2015 16:29
Show Gist options
  • Save kylelarkin/5289126 to your computer and use it in GitHub Desktop.
Save kylelarkin/5289126 to your computer and use it in GitHub Desktop.
AJAX include for WordPress
<?php
define('WP_USE_THEMES', false);
require_once('../../../../wp-load.php');
?>
<?php $term = $_POST['term']; ?>
<?php $the_query = new WP_Query(array('feature-types'=>$term)); ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?><!-- start loop -->
<article>
<h1><?php the_title(); ?></h1>
<?php the_advanced_excerpt(); ?>
<footer>By <?php the_author(); ?> on <?php echo get_the_date('F jS, Y'); ?></footer>
</article>
<?php endwhile; ?><!-- end loop -->
<?php if(!$the_query->have_posts())
echo 'There are currently no Features with this category. Please check back soon.';
?>
<?php wp_reset_postdata(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment