Skip Navigation

[Resolved] Updating a Multi-Line field?

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 1 voice and has 0 replies.

>
Author
Posts
#2680457

Apologies, this is one of those things that I'm sure I'm missing the forest for the trees and working way too hard on, but I'm stumped.

I have a Multiple Lines field:

line 1
line 2

I'd like to update it programmatically in a PHP function, adding a newline character and some text, to get this result:

line 1
line 2
line 3

update_post_meta strips backslashes, resulting in:

line 1
line 2nline 3

How do I do this correctly?

#2680458

Found this info:

PHP will only evaluate escape sequences if the string is enclosed in double quotes. If you use '\n', PHP will just take that as a literal string. If you use "\n", PHP will parse the string for variables and escape sequences and print a new line like you are expecting.

So, there it is.