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:

<ul>
<?php 
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);                                          
?>
</ul>

1 answer

Ktash 1851
1
point
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 about 6 years ago by Ktash
  • Dammit, I was close! Thanks man.. Leon Quinn about 6 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 about 6 years ago
  • Noted. I've done very little wordpress coding, so I didn't know that. Ktash about 6 years ago