Reputation: 6380
I have this bit of code:
<?php $fields = get_acf(); echo $fields->event_address; ?>
This outputs an address from a text area box in Wordpress. In that box I've written the address like this:
Address line 1,
Address line 2,
Address line 3
With the variable at the top it outputs all the info on one line (it doesn't recognise the address is over 3 lines), is it possible to do something clever to get it to display over 3 lines.
I know I could quite easily add more fields to Wordpress to show the 3 lines but I'd like something a bit more neat than that!
Upvotes: 0
Views: 316
Reputation: 14856
You could try solving this with pure css:
p {
white-space:pre;
}
The paragraph behaves like the <pre>
tag afterwards, breaking visually at line-breaks.
Upvotes: 1
Reputation: 1708
I think you may need nl2br()
Use it like so echo nl2br($fields->event_address);
In your text box if you just remove the lines between the addresses so they look like so
Address
Address
Address
That should do it...
Upvotes: 0