Having problems with a function
-
I have the following problem:
I don’t want WP adding wpautop to all pages, but only the ones I need, so I added this:
function my_wpautop_correction() { if( is_page() ) { remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); } if( is_page( array(79, 81) ) ) { add_filter( 'the_content', 'wpautop' ); add_filter( 'the_excerpt', 'wpautop' ); } } add_action('pre_get_posts', 'my_wpautop_correction');Seems to be working fine, but I am not sure if its the best way to write that function. I’ve tried this:
function my_wpautop_correction() { if( !( is_page(79) || is_page(81) ) ) { remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); } } add_action('pre_get_posts', 'my_wpautop_correction');But it doesnt work, what I am doing wrong? I want to add wpautop only to pages 79 and 81.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Having problems with a function’ is closed to new replies.