Custom Fields to Add Links
-
Hi, Right now I want to display 3 links on my article using custom fields. Here is what I did:
<div> <h3>Related Top Searched</h3> <ul> <li><?php { $gsubtitle = get_post_meta ($post->ID, 'gsubtitle', $single = true); if($gsubtitle !== '') echo $gsubtitle;} ?></li> <li><?php { $bsubtitle = get_post_meta ($post->ID, 'bsubtitle', $single = true); elseif($bsubtitle !== '') echo $bsubtitle;} ?></li> <li><?php { $ysubtitle = get_post_meta ($post->ID, 'ysubtitle', $single = true); if($ysubtitle !== '') echo $ysubtitle;} ?></li> </ul> </div>It serves the purpose but the only problem is that it shows even on posts that dont have the value. Like:
Related Top Searched > (blank) > (blank) > (blank)What I want to do?
I want to show this 3 custom fields only if they have a value. I know contidional tags can do it but I dont know how to apply. Also please help me make the code simple. Thanks a lot.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
The topic ‘Custom Fields to Add Links’ is closed to new replies.