Created
September 20, 2014 10:56
-
-
Save bichotll/7228cb9a98d1a5a381ee to your computer and use it in GitHub Desktop.
Get X posts by custom type
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 | |
//show just X posts for custome type | |
function modify_num_posts_for_clients($query) { | |
if ($query->is_main_query() && $query->is_post_type_archive('client') && !is_admin()) { | |
$query->set('posts_per_page', -1); | |
} | |
} | |
add_action('pre_get_posts', 'modify_num_posts_for_clients'); | |
function modify_num_posts_for_faq($query) { | |
if ($query->is_main_query() && $query->is_post_type_archive('faq') && !is_admin()) { | |
$query->set('posts_per_page', 20); | |
} | |
} | |
add_action('pre_get_posts', 'modify_num_posts_for_faq'); | |
function modify_num_posts_for_company_opinion($query) { | |
if ($query->is_main_query() && $query->is_post_type_archive('company_opinion') && !is_admin()) { | |
$query->set('posts_per_page', 10); | |
} | |
} | |
add_action('pre_get_posts', 'modify_num_posts_for_faq'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment