WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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. :)

share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer
Thank you this worked perfectly. :) – Nicole Sep 20 '12 at 13:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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