<?php add_action( 'pre_get_posts', 'pagination_fix_static_homepage' ); function pagination_fix_static_homepage( $query ) { $front_page_id = get_option( 'page_on_front' ); $current_page_id = $query->get( 'page_id' ); $is_static_front_page = 'page' === get_option( 'show_on_front' ); if ( $is_static_front_page && $front_page_id == $current_page_id ) { if ( get_query_var( 'paged' ) ) { $paged = get_query_var( 'paged' ); } elseif ( get_query_var( 'page' ) ) { $paged = get_query_var( 'page' ); } else { $paged = 1; } $paged = intval( $paged ); $query->set( 'paged', $paged ); } return $query; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter