Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Header configuration & styling (http://forum.bytesforall.com/forumdisplay.php?f=15)
-   -   [SOLVED] Specific content in logo area for a category (http://forum.bytesforall.com/showthread.php?t=957)

paulae Mar 25, 2009 08:34 PM

[SOLVED] Specific content in logo area for a category
 
I am almost able to do this myself, but I'm not sure of the PHP quite yet. Flynn, you helped me make the logo area into 3 table cells so I could put a logo image there plus an ad. I actually turned it into 2 cells.

Now I need to be able to have a different banner ad show in the right table cell just on a certain category. I know I'd do an "if is catgory ()" sort of statement, but I'm not sure where to put it in the header config file. My file right now has this in it:

Code:

// END of title/description
$logo_area .='
    <td colspan="2" rowspan="2" valign="middle" class="header-banner">
        <img src="http://www.larchmontgazette.com/wp27/wp-content/uploads/2009/03/gazebologopj1.jpg" align=left width=600 height=150>
    </td>
    <td rowspan="2" align="right" class="header-banner">
    <script language=javascript src="http://www.larchmontgazette.com/cgi-bin/csBanner2/csBanner.cgi?g=240&js=Y&ss=Y"></script>
    </td>
';

I want to have a different csBanner ad where the code in red is, on my Obituaries and Garden Guide category posts.

The obits page in action now shows a funeral home ad, the sponsor of the section, in the right sidebar, but I want to put a smaller version of it where the Sotheby's/Plates/Coughlin ads are now.

http://larchmontgazette.com/wp27/category/obits/

Flynn Mar 26, 2009 03:53 PM

PHP Code:

// END of title/description
$logo_area .='
    <td colspan="2" rowspan="2" valign="middle" class="header-banner">
        <img src="http://www.larchmontgazette.com/wp27/wp-content/uploads/2009/03/gazebologopj1.jpg" align=left width=600 height=150>
    </td>
    <td rowspan="2" align="right" class="header-banner">'
;

if ( 
is_category('......') OR is_category('.....') ) {

// Code for 2 specific categories
$logo_area .='<script language=javascript src="http://www.larchmontgazette.com/cgi-bin/csBanner2/csBanner.cgi?g=240&js=Y&ss=Y"></script>';

} else {

// Code for all other pages
$logo_area .='<script language=javascript src="http://www.larchmontgazette.com/cgi-bin/csBanner2/csBanner.cgi?g=240&js=Y&ss=Y"></script>';
}

$logo_area .='</td>
'



paulae Mar 27, 2009 02:20 PM

Ah. Getting closer. I should have been clearer, Flynn. Sorry.

I need separate code for Obituaries and Garden Guide. Each of these categories will have a different sponsor. So I need 3 instances of the Javascript banner ad code, for Obituaries, Garden Guide and the rest of the site. I'm unsure of how to arrange the 2 versions of the code, plus the site-wide code.

Should it be this?

Code:

// END of title/description
$logo_area .='
    <td colspan="2" rowspan="2" valign="middle" class="header-banner">
        <img src="http://www.larchmontgazette.com/wp27/wp-content/uploads/2009/03/gazebologopj1.jpg" align=left width=600 height=150>
    </td>
    <td rowspan="2" align="right" class="header-banner">';

if ( is_category('15')  ) {

// Code for 1 specific category
$logo_area .='<script language=javascript src="http://www.larchmontgazette.com/cgi-bin/csBanner2/csBanner.cgi?g=240&js=Y&ss=Y"></script>';

OR is_category('16') ) {

// Code for 1 specific category
$logo_area .='<script language=javascript src="http://www.larchmontgazette.com/cgi-bin/csBanner2/csBanner.cgi?g=240&js=Y&ss=Y"></script>';

} else {

// Code for all other pages
$logo_area .='<script language=javascript src="http://www.larchmontgazette.com/cgi-bin/csBanner2/csBanner.cgi?g=240&js=Y&ss=Y"></script>';
}

$logo_area .='</td>
';


Flynn Mar 27, 2009 07:14 PM

Then use this:

PHP Code:

// END of title/description
$logo_area .='
    <td colspan="2" rowspan="2" valign="middle" class="header-banner">
        <img src="http://www.larchmontgazette.com/wp27/wp-content/uploads/2009/03/gazebologopj1.jpg" align=left width=600 height=150>
    </td>
    <td rowspan="2" align="right" class="header-banner">'
;

if ( 
is_category('Obituaries') ) { 

// Code for category Obituaries
$logo_area .='<script language=javascript src="http://www.larchmontgazette.com/cgi-bin/csBanner2/csBanner.cgi?g=240&js=Y&ss=Y"></script>';

} elseif ( 
is_category('Garden Guide') ) { 

// Code for category Garden Guide
$logo_area .='<script language=javascript src="http://www.larchmontgazette.com/cgi-bin/csBanner2/csBanner.cgi?g=240&js=Y&ss=Y"></script>';

} else {

// Code for all other pages
$logo_area .='<script language=javascript src="http://www.larchmontgazette.com/cgi-bin/csBanner2/csBanner.cgi?g=240&js=Y&ss=Y"></script>';

}

$logo_area .='</td>
'



paulae Mar 27, 2009 08:39 PM

OK, closer!

However, now the correct ads show on the category main page, but not on individual posts in the category. Ignore the funeral home ad in the right sidebar. That was my work-around if I couldn't get the top ad to work.

http://larchmontgazette.com/wp27/category/obits/ , great!

But:

http://larchmontgazette.com/wp27/200...ind-reigelman/

There must be some other bit of code missing, no?

Flynn Mar 27, 2009 09:54 PM

Try this:

PHP Code:

// END of title/description
$logo_area .='
    <td colspan="2" rowspan="2" valign="middle" class="header-banner">
        <img src="http://www.larchmontgazette.com/wp27/wp-content/uploads/2009/03/gazebologopj1.jpg" align=left width=600 height=150>
    </td>
    <td rowspan="2" align="right" class="header-banner">'
;

if ( 
is_category('Obituaries') OR ( is_single() AND in_category('Obituaries') ) ) { 

// Code for category Obituaries
$logo_area .='<script language=javascript src="http://www.larchmontgazette.com/cgi-bin/csBanner2/csBanner.cgi?g=240&js=Y&ss=Y"></script>';

} elseif ( 
is_category('Garden Guide') OR ( is_single() AND in_category('Garden Guide') ) ) { 

// Code for category Garden Guide
$logo_area .='<script language=javascript src="http://www.larchmontgazette.com/cgi-bin/csBanner2/csBanner.cgi?g=240&js=Y&ss=Y"></script>';

} else {

// Code for all other pages
$logo_area .='<script language=javascript src="http://www.larchmontgazette.com/cgi-bin/csBanner2/csBanner.cgi?g=240&js=Y&ss=Y"></script>';

}

$logo_area .='</td>
'



paulae Mar 28, 2009 06:08 AM

OK, that was the trick! Thank you so much, Flynn!

Why not make this an option in the theme options area? I would think many people would want to be able to use the logo area this way. Or have a separate ad banner spot up there, easily configurable for different sizes of logos and ads. The way I did it, with a TD spanning 2 columns for the logo and a TD for the ad works nicely. The refinement of letting the user show different ads in different categories is really super.

Maybe the person wouldn't put ads up there, just different kinds of images for different parts of his site.

Atahualpa is already so flexible, give us this added toy. Please?

For my part, I fear that the person who will eventually take over my job will not be as willing to get into the core files as I have been, so making this easy is important.


All times are GMT -6. The time now is 11:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.