Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'pre_get_posts', 'be_change_event_posts_per_page' );
- /**
- * Change Posts Per Page for Event Archive
- *
- * @author Bill Erickson
- * @link http://www.billerickson.net/customize-the-wordpress-query/
- * @param object $query data
- *
- */
- function be_change_event_posts_per_page( $query ) {
- if( $query->is_main_query() && !is_admin() && is_home() ) {
- $ppp = get_option( 'posts_per_page' );
- $offset = 1;
- if ( !$query->is_paged() ) {
- $query->set( 'posts_per_page', $offset + $ppp );
- } else {
- $offset = $offset + ( ($query->query_vars['paged']-1) * $ppp );
- $query->set( 'posts_per_page', $ppp );
- $query->set( 'offset', $offset );
- }
- }
- }
- function homepage_offset_pagination( $found_posts, $query ) {
- $offset = 1;
- if( $query->is_home() && $query->is_main_query() ) {
- $found_posts = $found_posts - $offset;
- }
- return $found_posts;
- }
- add_filter( 'found_posts', 'homepage_offset_pagination', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement