-
-
Save celsofabri/25d75f5240aad1dca202 to your computer and use it in GitHub Desktop.
Limit Number of Sticky Posts to Show / Limitando Número de Posts Fixos Exibidos
This file contains hidden or 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 | |
$sticky = get_option( 'sticky_posts' ); | |
/* Sort the newest one at the top */ | |
rsort( $sticky ); | |
/* Get the 2 newest stickies (change 2 for a different number) */ | |
$sticky = array_slice( $sticky, 0, 2 ); | |
/* Query Post */ | |
$args = array( | |
'post_type' => array( 'post' ), | |
'post__in' => $sticky, | |
'ignore_sticky_posts' => 2 | |
); | |
query_posts($args); | |
?> | |
<!-- Output Html Here --> | |
<?php endif; wp_reset_query(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment