get_post_custom value
-
Hi,
I’m trying to build a staff page for my theme. The staff members can enter their social media profiles, like twitter, facebook, etc. In total there are 10 custom fields.
In my single-staff.php I would like to display all the staff members info.
At the moment I use this code:<?php $custom = get_post_custom($post->ID); // Get all custom fields ?> <?php if ($custom['staff_twitter'][0] != '') { // Display Twitter ?> <a href="https://www.twitter.com/<?php echo $custom['staff_twitter'][0]; ?>">Twitter</a> <?php } ?>
So the link will only show up, if a staff member entered a twitter url. But when a member leaves the twitter field blank, I’m getting this error in WP_Debug mode:
Notice: Undefined index: tw_staff_twitterIs there something I’m doing wrong?
Thanks in advance!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘get_post_custom value’ is closed to new replies.