2016-05-29 9 views
0

私は私のwordpress themefunction.phpにこのコードを書いた:特定WordPressのページに機能を追加

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); 

どのように私は5580特定のページ-IDには、唯一の特定のワードプレスのページのために、このコードを読み込むことができますか?

は、さてあなたは、is_page()を使用し、同じのためページスラグを渡すことができ

答えて

1

..youがページスラグ、タイトル、この機能のid

例を渡すことができますありがとうあなたのidがある場合 - その後、is_page( '5580')

を使用しますが、私たちはほとんどがthe_excerptですブログのEDあなたがブログを探しているので、もし、より多くの詳細については、下のリンクを参照してください同じ

ためis_home()を使用する - このようhttps://developer.wordpress.org/reference/functions/is_page/

0

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); 
} 
関連する問題