I need to create an if statement for the nbsp (space).
<?php echo get_post_meta($post->ID, 'the_term', true); echo ' '; ?>
This is at the front of a line:
<h2><?php echo get_post_meta($post->ID, 'the_term', true); echo ' '; ?>Example
If the term exists, then it'll show 'Term Example'. If not, I need to show 'Example'. But right now, without an if, I get ' Example'. Note the ugly space.
I think I'd done this before, using this:
<?php if (post_custom('the_term')) {
echo get_post_meta($post->ID, 'the_term', true); echo ' ';
} else {
echo '';
?>
... but it's not working. Server error.
I also tried this:
<?php $the_term_check = get_post_meta($post->ID, 'the_term', true);
if (!empty($the_term_check))
echo '<h2>'; echo get_post_meta($post->ID, 'the_term', true); echo ' Example'</h2>';
if (empty($the_term_check))
echo'<h2>Example</h2>';
?>
Still not it. This one echos 'Example' twice -- and one of them doesn't even have the right HTML markup.
Either plain PHP or WordPress-specific code would work, as this is pulling the custom meta from a custom post type -- if it exists.
Any ideas?