Last active
April 11, 2020 23:24
-
-
Save wplit/f2e00c6e4ebcb0e411a617e484ad2a4e to your computer and use it in GitHub Desktop.
add offset to post category
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
| add_action( 'pre_get_posts', 'lit_offset_category_filter' ); | |
| function lit_offset_category_filter($query) { | |
| if ( ! is_admin() && $query->is_main_query() ) { // Apply to main WP query | |
| if( $query->is_category()) { // Only on category pages | |
| $offset = '3'; // Number of posts to offset | |
| $query->set( 'offset', $offset ); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment