[英]WordPress - text area linebreaks as seperate P tags (without creating empty p-tags where linebreaks where)
I have a custom textarea are that I normally just output using ' nl2br
'. 我有一个自定义的textarea,通常我只是使用'
nl2br
'输出。 In this particular case I need to wrap them in separate Paragraph tags, instead of have '<br/>'
. 在这种情况下,我需要将它们包装在单独的段落标签中,而不要使用
'<br/>'
。
I'm currently using this: 我目前正在使用此:
$memberDescription = '<p>' . implode('</p><p>', array_filter(explode("\n", get_post_meta( get_the_ID(), 'members_' . $z . '_description', true )))) . '</p>';
My issue is that when I echo this out, it also outputs empty Paragraph tags (im guessing where extra line breaks are). 我的问题是,当我将其回显时,它还会输出空的Paragraph标记(我猜想多余的换行符在哪里)。
Any tips or tricks on how to alter this to remove the empty P-tags, or have them not even outputted, to begin with, would be greatly appreciated. 首先,将有关于如何更改此技巧以删除空的P标签或什至不输出它们的任何提示或技巧。
答案就是上面描述的@fubar:
$memberDescription = '<p>' . implode('</p><p>', array_filter(explode("\r\n", get_post_meta( get_the_ID(), 'members_' . $z . '_description', true )))) . '</p>';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.