Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.