-
-
Save About2git/1eb049b483404ad153f6 to your computer and use it in GitHub Desktop.
Setting the number of posts on Posts page for handhelds in Genesis.
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 | |
| //* Do NOT include the opening php tag | |
| add_action( 'pre_get_posts', 'sk_change_posts_per_page' ); | |
| /** | |
| * Set Posts Per Page on Handhelds (Tablets and Mobiles) | |
| * | |
| * Context: Posts page | |
| * | |
| * @author Sridhar Katakam | |
| * @link http://sridharkatakam.com/ | |
| */ | |
| function sk_change_posts_per_page( $query ) { | |
| if ( ! wp_is_mobile() ) { | |
| return; | |
| } | |
| if( $query->is_main_query() && !is_admin() && is_home() ) { | |
| $query->set( 'posts_per_page', '5' ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment