Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Here's what I've found based off this question at Stack Overflowquestion at Stack Overflow

You'll have to remove wpautop entirely then add it back in whenever needed, which I agree in the linked comment, is unfortunate:

remove_filter('the_content', 'wpautop');
remove_filter('the_excerpt', 'wpautop');

/** Change How The Content Works **/
function no_content_autop($content){
    global $post;
    
    if($post->post_type != 'services')
        return wpautop($content);
        
    return $content;
}
add_filter('the_content','no_content_autop');

/** Change How The Excerpt Works **/
function no_excerpt_autop($content){
    global $post;
    
    if($post->post_name != 'services')
        return wpautop($content);
        
    return $content;
}
add_filter('the_excerpt','no_excerpt_autop');

The question is old so you may want to watch this question for a day or two and see if somebody comes up with an improved answer.

Here's what I've found based off this question at Stack Overflow

You'll have to remove wpautop entirely then add it back in whenever needed, which I agree in the linked comment, is unfortunate:

remove_filter('the_content', 'wpautop');
remove_filter('the_excerpt', 'wpautop');

/** Change How The Content Works **/
function no_content_autop($content){
    global $post;
    
    if($post->post_type != 'services')
        return wpautop($content);
        
    return $content;
}
add_filter('the_content','no_content_autop');

/** Change How The Excerpt Works **/
function no_excerpt_autop($content){
    global $post;
    
    if($post->post_name != 'services')
        return wpautop($content);
        
    return $content;
}
add_filter('the_excerpt','no_excerpt_autop');

The question is old so you may want to watch this question for a day or two and see if somebody comes up with an improved answer.

Here's what I've found based off this question at Stack Overflow

You'll have to remove wpautop entirely then add it back in whenever needed, which I agree in the linked comment, is unfortunate:

remove_filter('the_content', 'wpautop');
remove_filter('the_excerpt', 'wpautop');

/** Change How The Content Works **/
function no_content_autop($content){
    global $post;
    
    if($post->post_type != 'services')
        return wpautop($content);
        
    return $content;
}
add_filter('the_content','no_content_autop');

/** Change How The Excerpt Works **/
function no_excerpt_autop($content){
    global $post;
    
    if($post->post_name != 'services')
        return wpautop($content);
        
    return $content;
}
add_filter('the_excerpt','no_excerpt_autop');

The question is old so you may want to watch this question for a day or two and see if somebody comes up with an improved answer.

Source Link
Howdy_McGee
  • 20.8k
  • 24
  • 91
  • 175

Here's what I've found based off this question at Stack Overflow

You'll have to remove wpautop entirely then add it back in whenever needed, which I agree in the linked comment, is unfortunate:

remove_filter('the_content', 'wpautop');
remove_filter('the_excerpt', 'wpautop');

/** Change How The Content Works **/
function no_content_autop($content){
    global $post;
    
    if($post->post_type != 'services')
        return wpautop($content);
        
    return $content;
}
add_filter('the_content','no_content_autop');

/** Change How The Excerpt Works **/
function no_excerpt_autop($content){
    global $post;
    
    if($post->post_name != 'services')
        return wpautop($content);
        
    return $content;
}
add_filter('the_excerpt','no_excerpt_autop');

The question is old so you may want to watch this question for a day or two and see if somebody comes up with an improved answer.