Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

257
Views
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'. In this particular case I need to wrap them in separate Paragraph tags, instead of have '<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).

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.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

answer was what @fubar described above:

$memberDescription = '<p>' . implode('</p><p>', array_filter(explode("\r\n", get_post_meta( get_the_ID(), 'members_' . $z . '_description', true )))) . '</p>';
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!