Reputation: 39
I wrote this code in function.php
of my wordpress theme
:
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'wpse_custom_wp_trim_excerpt');
function wpse_excerpt_length( $length ) {
return 40;
}
add_filter( 'excerpt_length', 'wpse_excerpt_length', 999 );
How can I load this code only for a specific WordPress page, in particular page-id 5580?
Thank you
Upvotes: 0
Views: 1340
Reputation: 301
Like this:
if( is_page( 5580 ) {
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'wpse_custom_wp_trim_excerpt');
function wpse_excerpt_length( $length ) {
return 40;
}
add_filter( 'excerpt_length', 'wpse_excerpt_length', 999 );
}
Upvotes: 1
Reputation: 2157
Well you can use is_page() and pass page slug for the same ..you can pass page slug , title , Id anything in this function
Example if your id is - 5580 then use is_page('5580')
but the_excerpt is mostly used for blog so if you are looking for blog then use is_home() for the same
Refer below link for more details - https://developer.wordpress.org/reference/functions/is_page/
Upvotes: 0