Created
July 17, 2016 01:32
-
-
Save salcode/b6c5eb8668e533a7c3ae2144eb2fd110 to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* Set the number of posts on the Custom Post Type archive for `fe_recipe` to 5. | |
*/ | |
add_action( 'pre_get_posts', 'fe_modify_number_of_posts_per_page' ); | |
/** | |
* Modify Posts Per Page for CPT `fe_recipe` | |
* | |
* @param WP_Query $query The current query about to be run. | |
*/ | |
function fe_modify_number_of_posts_per_page( $query ) { | |
if ( ! $query->is_main_query() ) { | |
return; | |
} | |
if ( | |
isset( $query->query['post_type'] ) | |
&& 'fe_recipe' === $query->query['post_type'] | |
) { | |
$query->set( 'posts_per_page', 5 ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment