Last active
August 29, 2015 14:06
-
-
Save wpmark/aa388261d0ef58938218 to your computer and use it in GitHub Desktop.
Show Only 5 Blog Posts on Home Page
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 | |
/*************************************************************** | |
* Function wpmark_alter_homepage_posts_query() | |
* Alter query on homepage for show just 5 posts | |
***************************************************************/ | |
function wpmark_alter_homepage_posts_query( $query ) { | |
/* check this is not the main query, the admin - if so bail early */ | |
if( ! $query->is_main_query() || is_admin() ) | |
return; | |
/* check whether this is the job post type archive or a job tax archive */ | |
if( is_home() ) { | |
/* set job archives to show 10 posts per page */ | |
$query->set( 'posts_per_page', 5 ); | |
} | |
return; | |
} | |
add_action( 'pre_get_posts', 'wpmark_alter_homepage_posts_query', 10 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment