Last active
August 7, 2022 16:52
-
-
Save frontend-coder/92e994899ac8fd8c325c3bc42767eb9b to your computer and use it in GitHub Desktop.
45. Как изменить количество тумб постов на одной страницы при пагинации #wordpress
This file contains 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
function domain_set_posts_per_page($query) { | |
$domein_custom_post_page = ''; | |
// отримати значення кількості постів з адмінки | |
if(domain_get_option('domein_posts_per_page') ) { | |
$domein_custom_post_page = domain_get_option('domein_get_option'); | |
} | |
if( !empty($domein_custom_post_page) ) { | |
if(!is_admin() && $query->is_main_query() && is_post_type_archive('name_custom_post_type') ) { | |
$query->set('posts_per_page', $domein_custom_post_page ); | |
} | |
} | |
} | |
add_action('pre_get_posts','domain_set_posts_per_page'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment