Last active
July 24, 2019 17:46
-
-
Save atanas-dev/7de450a79dcdf51a0991cae98f5ab3c7 to your computer and use it in GitHub Desktop.
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 | |
// This code is UNTESTED! | |
function foo_add_class_to_first_three_posts_or_whatever( $post_class ) { | |
global $wp_query; | |
if ( $wp_query && $wp_query->current_post < 3 && is_main_query() && ! is_singular() && ! is_search() ) { | |
$post_class .= ' one-of-the-top-trio'; | |
} | |
return $post_class; | |
} | |
add_filter( 'post_class', 'foo_add_class_to_first_three_posts_or_whatever' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment