Last active
December 16, 2015 00:29
-
-
Save caseymhunt/5347570 to your computer and use it in GitHub Desktop.
A wordpress functions.php code snippet that overrides the user controlled post limit so that certain post types or pages will display all or a declared number of posts rather than obey this limit.
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
| <? // Open tag added for proper color formatting- DO NOT COPY THIS LINE | |
| // Function to override the set value of Post Limit in Wordpress | |
| function theme_post_override ( $query ) { | |
| // Only act on author pages | |
| if ( is_author() ) { | |
| // Display ALL posts | |
| $query->set( 'posts_per_page', -1 ); | |
| return; | |
| } | |
| // Act on 'custom' post type when displaying archive of posts | |
| if ( is_post_type_archive(' custom' ) ) { | |
| // Display 10 posts | |
| $query->set( 'posts_per_page', 10 ); | |
| } | |
| } | |
| add_action( 'pre_get_posts', 'theme_post_override', 1); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment