Skip to content

Instantly share code, notes, and snippets.

@fernandiez
Last active September 6, 2016 17:06
Show Gist options
  • Save fernandiez/e1f935be313257430082794f063d09b3 to your computer and use it in GitHub Desktop.
Save fernandiez/e1f935be313257430082794f063d09b3 to your computer and use it in GitHub Desktop.
WordPress WP_Query with just sticky posts - page.php or index.php template
<?php
/**
* WordPress WP_Query with just sticky posts - page.php or index.php template
**/
get_header(); // loads header.php template ?>
<?php $custom_query = new WP_Query('posts_per_page=1'); ?>
<div id="wrap-sample" class="blog-sample clearfix">
<?php
// Loop through $custom_query posts
while ($custom_query->have_posts()) : $custom_query->the_post();
get_template_part( 'content', get_post_format() );
endwhile;
?>
</div><!-- /wrap -->
<?php wp_reset_postdata(); // reset the query ?>
<?php get_footer(); //get footer.php template ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment