Last active
September 6, 2016 17:06
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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