Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('pre_get_posts', 'td_modify_main_query_for_blog_page');
- function td_modify_main_query_for_blog_page($query) {
- //checking for blog page and main query
- if(!is_admin() and $query->is_main_query() and (is_front_page() and is_home() )) {
- //get the number of page where on
- $paged = get_query_var('paged');
- //get the limit of posts on the page
- $limit = get_option('posts_per_page');
- //offset is hardcoded because of big grid
- $offset = 5;
- // offset + custom pagination - if we have offset, wordpress overwrites the pagination and works with offset + limit
- if(empty($query->is_feed)) {
- if ( ! empty( $offset ) and $paged > 1 ) {
- $query->set( 'offset', $offset + ( ( $paged - 1 ) * $limit ) );
- } else {
- $query->set( 'offset', $offset );
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment