Skip to content

Instantly share code, notes, and snippets.

@eri-trabiccolo
Last active August 29, 2015 14:16
Show Gist options
  • Save eri-trabiccolo/f0c9e74fcf0e496ec543 to your computer and use it in GitHub Desktop.
Save eri-trabiccolo/f0c9e74fcf0e496ec543 to your computer and use it in GitHub Desktop.
show two posts without pagination in home
add_action('pre_get_posts', 'show_two_posts_in_home');
function show_two_posts_in_home($query){
if ( ! is_admin() && $query -> is_main_query() && tc__f('__is_home') && ! tc__f('__is_home_empty') ){
$query->set('posts_per_page', 2);
// remove pagination
add_filter('tc_show_post_navigation', '__return_false', 999);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment