Conditional custom fields
-
Alright, so the website for my high school journalism program has custom fields for the writer’s name and their corresponding job title. Here’s the code to display them in posts:
<?php $writer = get_post_meta($post->ID, writer, true); $jobtitle = get_post_meta($post->ID, jobtitle, true); if ($writer) { ?><?php echo $writer; if ($jobtitle) { ?>, <?php echo $jobtitle; }} ?>It comes out to look like this: “Writer, Jobtitle”. I’d like for these to be conditional with the word “None” for when the post lacks a writer/jobtitle. How could I achieve this? Thanks in advance.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Conditional custom fields’ is closed to new replies.