Function to display ad from theme options
-
I’ve been lurking for a while, but this is my first post. I’m a bit of a PHP newbie so please bare with me!
I’ve created wordpress theme options for a link url and image url for a 468×60 ad in between the first and second post in my blog’s homepage.
The link URL is:
$bbf_content_ad_linkI know these are functional because if I insert them in a basic anchor and place them directly in index.php, the ad shows up fine. Of course, if there is nothing entered in the fields on the theme options page, you get ugly X’s in just about every browser besides Firefox.
Basically, I’m trying to create a function in functions.php that will show the ad when I enter the link and url on the options page, but show nothing if the fields on the options page are left blank.
Like I said, I’m a PHP newbie, so bare with me if this is horrible, but here’s what I have so far:
function content_ad() { ?>
<?php if($bbf_content_ad_image) : ?>
"><img src="<?php echo $bbf_content_ad_image; ?>">
<?php else : ?>
<?php endif; ?>
<?php }And in index.php I’ve got:
<div id="content-ad">
<?php if(!$show_ads){ ?>
<?php content_ad() ?>
<?php $show_ads = 1; } ?>
</div>As I’ve got it set up, nothing is showing up. After a lot of google searching and forum searching, I’m a bit lost. Any help would be greatly appreciated!
Adam
-
You did not specify a blog address or reason for posting when you created this topic.
This support forum is for blogs hosted at WordPress.com. If your question is about a self-hosted WordPress blog then you’ll find help at the WordPress.org forums.
If you don’t understand the difference between WordPress.com and WordPress.org, you may find this information helpful.
If you forgot to include a link to your blog, you can reply and include it below. It’ll help people to answer your question.
This is an automated message.
- The topic ‘Function to display ad from theme options’ is closed to new replies.