Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.

Thread Tools Display Modes
Share |
Old 11-15-2008, 01:07 PM
a!!!!1 a!!!!1 is offline
Junior Member
Join Date: 11-15-08
Posts: 1
iTrader: 0 / 0%
PHP / Wordpress - displaying code to only designated categories

I'd like to display different ads based on what category people are viewing (ie. if they click the category archive and/or view a single post in a designated category, it shows an ad related to that category). I have separate ad codes that correspond to category topics, so what I'd like to know is: is there any way to do some kind of "if category = ___, then display ___" (I don't know PHP I'm just guessing that would be the gist of it)? Thanks.
Reply With Quote



Old 11-15-2008, 04:40 PM
ScriptMan's Avatar
ScriptMan ScriptMan is online now
Super Moderator
Join Date: 02-10-07
Location: Central Kentucky
Posts: 14,016
iTrader: 4 / 100%
Your pseudo code is more or less correct but I am not sure how you would implement it with wordpress.

I assume these are ads you have sold? Yahoo, adsense and a few others target the ad to the page content so what you want to do isn't necessary.

The basic concept is to include each ad code in an individual file and then include that file. Something along the lines of:

$caterory= the category as retrieved form the mysql query
If $category=="cats";
include ("cats.php");
else If $category=="dogs"
include ("dog.php";

Note I have not included all the necessary { } in the example above. This is just a quick example.
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Wordpress code problem ...please help! FREEativeMedia Coding Forum 3 03-07-2007 08:14 AM
Wordpress Show Only Certain Categories In Recent Posts waffles Blogging Forum 0 11-10-2006 06:37 AM
Where do you put the code for a favicon in Wordpress? Nick Coding Forum 8 07-14-2006 02:06 PM
Wordpress and php code? JuggoPop Blogging Forum 6 04-10-2006 12:02 PM

V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory

All times are GMT -7. The time now is 01:35 AM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC