Friday 15 August 2014

php - Having trouble with a function in Wordpress -


I have the following problem:

I do not want WP to add wpautop to all pages, but only People I need, so I added:

  function my_wpautop_correction () {if (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 work well, but I'm not sure it's the best way to write that work. I have tried to do 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 that does not work, what am I doing wrong? I only want to add wpautop to pages 79 and 81.

Try it out:

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

No comments:

Post a Comment