[Plugin: Custom Field Template] variable data show/not show
-
Hi guys.
I’m using wp 2.9.2 and v 1.6.5 of the Custom Field Template
I’m having an issue w/ the custom field template plugin. I don’t think it’s something wrong with the plugin. It’s probably my ignorance with PHP that’s causing this problem.
Let me set it up so that you can get a better idea of what I’m trying to accomplish.
Basically I’m building a site for a client that is completely computer illiterate. They have an “employee section” on their site that will allow them to enter name, position, bio, etc. I’ve got it set up so that part all works fine.
What I also need is a way for them to enter links to various Social Media sites, twitter, fb, wp blogs, blogger blogs, myspace, etc etc.
I have created custom fields where they can enter the URL of the various sites.
What I’m hoping I can do is set it up so that I have an icon for each external link, and those icons will only show if they enter the URL into the specific field.
For instance, they might have 3 employees. One has twitter, facebook, the other wordpress, blogger, the other all three.
Anyway, I’ve played with various functions, but none of them seem to work right. I’m guessing this is simple enough, but I really don’t know enough about PHP.
Here’s what I was attempting:
in my functions.php file I have this:// custom field plugin function getCustomField($theField) { global $post; $block = get_post_meta($post->ID, $theField); if($block){ foreach(($block) as $blocks) { echo $blocks; } } }
And these are the different bits of code I was trying in my template file to display the data.
<?php $facebookLink = get_post_meta($post->ID, 'fbLink', true); echo "a href='"; echo get_post_meta($facebookLink); echo "' target='_blank'><img src='/images/fbLink.gif' />"; ?>
<?php $facebookLink = get_post_meta($post->ID, 'fbLink', true, ); if ($facebookLink > 0) { echo "<a href='$facebookLink'><img src='/images/fbLink.gif' /></a>"; ?>
<?php if (getCustomField('fbLink') > 0) { echo ("<a href='"); echo ($fbLink); echo ("'><img src='/images/fbLink.gif' />"); } ?>
etc, etc.
Anyway, any help would be greatly appreciated!
Thanks everyone!
- The topic ‘[Plugin: Custom Field Template] variable data show/not show’ is closed to new replies.