Skip to content

Instantly share code, notes, and snippets.

@About2git
Forked from srikat/functions.php
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save About2git/1eb049b483404ad153f6 to your computer and use it in GitHub Desktop.

Select an option

Save About2git/1eb049b483404ad153f6 to your computer and use it in GitHub Desktop.
Setting the number of posts on Posts page for handhelds in Genesis.
<?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