I know this is probably going to sound like a beginner question ... to which it is in some sort.

I have this statement in my one plugin that i am working on:

add_post_meta($newpostid, 'name', $formdata['your-first-name'].$formdata['your-last-name']);

Which in turn will add FirstnameLastname in a custom field.

What i would like to do is add a space between the first and last name like this:

Firstname Lastname

I have tried using statements such as:

add_post_meta($newpostid, 'name', $formdata['your-first-name']. echo '&nbsp' . $formdata['your-last-name']);

But obviously that is not going to parse correctly. Is there any Idea on how I can achieve this?

Any help would be welcome. :)

1 Answer 1


Do this instead:

add_post_meta($newpostid, 'name', $formdata['your-first-name'] . ' ' . $formdata['your-last-name']);

This uses PHP string concatenation to add a space; the echo isn't necessary in in this instance because WP will do it itself, later. You probably can't force a non-breaking space there, either, since WP will escape all its output.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.