the_content is always surrounded by paragraphs (how to disable or remove them)?

wordpress.stackexchange https://wordpress.stackexchange.com/questions/7741

  •  16-10-2019
  •  | 
  •  

سؤال

the_content is always surrounded by paragraphs, it doesn't matter if I'm in HTML view and there's nothing there. Does WordPress have a function to remove them? IS there any way?

هل كانت مفيدة؟

المحلول

Removing the filter that adds the P is the best option.

remove_filter('the_content','wpautop');
remove_filter('the_content','shortcode_autounp'); // You may want to do this aswell

نصائح أخرى

You can implement your own function in your theme's function.php file and use it instead of "the_content"

function my_content($post){
    $content = apply_filters('the_content', $post->post_content); // added to parse shortcodes
    $content = str_replace(']]>', ']]&gt', $content); // added to parse shortcodes
    echo content;
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى wordpress.stackexchange
scroll top