Simple fields issue with post field gettin value of 0

Hi,

I’m doing some changes on a WP site using simple fields, which i’m not very confident with.

I have two field types, post and url. And if the post field is empty (no post selected) i want to output the value of the url field. The problem is if nothing is selected in the post field it still gets a value of 0.

Here is my code:

<?php
$slide_url = simple_fields_value('slideshow_slide_url');
$slide_extern_url = simple_fields_value('slideshow_slide_extern_url');
$slide_readmore = (is_numeric($slide_url)) ? '<a href="'.get_permalink($slide_url).'">Read more &raquo;</a>' : '<a href="'.$slide_extern_url.'" target="_blank">Read more &raquo;</a>';
?>

<?php echo $slide_readmore; ?>

I have not written this code,except the else part of the shorthand. Also I would want to not output any markup if none of these field has values. Is this possible? Would be very thankful for help.

Using the ternary operator gives you an either … or type of solution. So in either case you would get some markup. Why not use “if … else if … else” ?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.