I have built a custom options panel which allows site owners to enter their social profiles. I then use the second code to make the links appear in the theme.
When no link is entered in the options panel, I would like there to be no link called on the page where the code is being called. Currently, it provides me with a link to the homepage of my site.
Take a look: http://themeforward.com/demo2/ – the green box is the facebook link, the purple is the google link
I know what you’re thinking – why not just leave it the way it is? Because, I’m styling each link with a background image rather than using normal text links… so if I just leave it this way we will still have an image showing up advertising a social site presence, but it won’t be linked. The styling can be found here: http://pastebin.com/m3PrBDae I think that may be affecting this.
In my functions
array( "name" => "Facebook Page",
"desc" => "Enter your Facebook address. (Must include http://)",
"id" => $shortname."_facebook",
"type" => "text",
"std" => ""),
array( "name" => "Google Plus",
"desc" => "Enter your Google Plus address. (Must include http://)",
"id" => $shortname."_google_plus",
"type" => "text",
"std" => ""),
How I call them
<a href="<?php echo get_option('to_facebook'); ?>"></a>
<a href="<?php echo get_option('to_google_plus'); ?>"></a>
Check if get_option returns a value and if it is not blank, then output the links.
This should work for you:
You could try something like: