Wordpress - apply remove_filter on only one page

I insert several pages on one page (with the showmultiplepages plugin), and one page contains a php file (with exec-php). I want to disable the filter only for this included page. If I add

remove_filter( 'the_content', 'wpautop' );

on my included page, on any page, starting from this page, there will also be no filters.

Is there any tag like 'the_page' so that only the page will not have a filter?

Thanks for the help.

+5
source share
4 answers

I suggest creating a page template for "one page containing a php file (using exec-php)." Then add the if statement from the remove_filter (...) statement.

if (!is_page_template('my-page.php'))
  remove_filter('the_content', 'wpautop');

Hope this works out .; R

+3

, , , , (, ) , functions.php :

add_filter('the_content', 'specific_no_wpautop', 9);
function specific_no_wpautop($content) {
    if (is_page('YOUR PAGE')) { // or whatever other condition you like
        remove_filter( 'the_content', 'wpautop' );
        return $content;
    } else {
        return $content;
    }
}
+9

mroncetwice, , ; , , . ( ) , .


wpautop :

/**
 * Allow or remove wpautop based on criteria
 */
function conditional_wpautop($content) {
    // true  = wpautop is  ON  unless any exceptions are met
    // false = wpautop is  OFF unless any exceptions are met
    $wpautop_on_by_default = true;

    // List exceptions here (each exception should either return true or false)
    $exceptions = array(
        is_page_template('page-example-template.php'),
        is_page('example-page'),
    );

    // Checks to see if any exceptions are met // Returns true or false
    $exception_is_met = in_array(true, $exceptions);

    // Returns the content
    if ($wpautop_on_by_default==$exception_is_met) {
        remove_filter('the_content','wpautop');
        return $content;
    } else {
        return $content;
    }
}
add_filter('the_content', 'conditional_wpautop', 9);
+1

?

add_filter('the_content', 'specific_no_wpautop', 9);
function specific_no_wpautop($content) {
    global $post;
    if (is_sangle('5136') || ('3820')){ // or whatever other condition you like
        remove_filter( 'the_content', 'wpautop' );
        return $content;
    } else {
        return $content;
    }
}
-3

All Articles