I want to show the 4 echoed results below in a bulleted list. Don't know where or how to insert the <li> and </li> tags:

global $wp_query;
$postid = $wp_query->post->ID;                                                  
echo get_post_meta($postid, 'Job Location', true);
echo get_post_meta($postid, 'Job Type', true);
echo get_post_meta($postid, 'Employer', true);
echo get_post_meta($postid, 'How To Apply', true);                                          

1 answer

Ktash 1851
This was chosen as the best answer

There are two ways of doing this. Well, there are lots, but two ways that make the most sense, and one can be done even a little cleaner with configuration of your php.ini file.

The first:

<?php echo "<li>" . get_post_meta($postid, 'Job Location', true) . "</li>"; ?>

The second:

<li><?php echo get_post_meta(...); ?></li>

which, if your php.ini file is configured correctly, can be condensed to:

<li><?= get_post_meta(...) ?></li>

Personally, I prefer the second method, though either get the job done.

Answered over 8 years ago by Ktash
  • Dammit, I was close! Thanks man.. Leon Quinn over 8 years ago
  • WordPress coding standards don't allow for the short PHP code, and suggest the second method, keeping the PHP code wrapped in html. Tony Crockford over 8 years ago
  • Noted. I've done very little wordpress coding, so I didn't know that. Ktash over 8 years ago