WordPress的帖子编辑器省略换行符吗?

在撰写WordPress帖子时, 在可视模式下会在文本编辑器中显示换行符, 但在HTML模式下只会出现&nbsp而不是BR标签。

如何在每个换行符处添加BR标签, 而不是默认情况下&nbsp?


#1


你可以在functions.php中使用这些代码来删除用于消除线路制动器的过滤器

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

function my_tinymce_config( $init ) {
    $init['remove_linebreaks'] = false; 
    $init['convert_newlines_to_brs'] = true; 
    $init['remove_redundant_brs'] = false; 
    return $init;
}
add_filter('tiny_mce_before_init', 'my_tinymce_config');

#2


你可以使用php的nl2br()函数。例如:

nl2br(get_the_content());

#3


如果要在Wordpress内容屏幕中添加换行符, 可以通过为<br />标签分配一个类来实现, 例如:

<br class="break" />

而Wordpress不会将其删除。

来源:

https://www.srcmini02.com/66752.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_40342.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?