Skip to content

Instantly share code, notes, and snippets.

@pixelcoder
Created April 20, 2015 03:42
Show Gist options
  • Save pixelcoder/a8f709fc2de163c48e9e to your computer and use it in GitHub Desktop.
Save pixelcoder/a8f709fc2de163c48e9e to your computer and use it in GitHub Desktop.
WordPress: Get sticky posts
<?php
$sticky = get_option('sticky_posts');
$args = array(
'posts_per_page' => 6,
'post__in' => $sticky
);
$px_query = new WP_Query($args);
?>
<?php if(!empty($sticky)) : ?>
<?php while($px_query->have_posts()) : $px_query->the_post(); ?>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment