Wordpress Themes - WP Forum at BFA
Click Here To DONATE! Support the theme development, get more attention and additional benefits based on your donation level. Your forum name will be highlighted.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Center area post/pages »

Conditional category styling = PHP


Build custom WP THEMES, without
coding.
Click here for THEMEFRAME

From the author of Atahualpa, the #1 most
downloaded (700,000+) theme @ wordpress.org
  #1  
Old Dec 17, 2010, 09:01 AM
bender57's Avatar
bender57
 
16 posts · Apr 2010
France
Hi everyone !

I am so stuck with a conditional display in PHP.

Could you please help to fix the following conditions:

What I want to do (in a VBA way...) in the LOOP

If category='uncategorised'
then "Do not display KICKER"
else
If category='red'
kicker background=red
if category='blue'
kicker background=blue


The ultimate goal is to display a background image different per category in the KICKER only on the homepage and display nothing if no category.

I've got this code but full a errors...

Code:
<?php bfa_post_kicker( if (in_category('red'))
{ ('<div class="post-kicker">','</div>') ?>
<?php } ?>
Thanks for helping a poor PHP guy...
  #2  
Old Dec 17, 2010, 04:42 PM
STB
 
762 posts · Apr 2010
1) where are you putting that code?

2) dont forget content and styling are different things:
- 'the loop' governs the content (posts etc.)
- 'css' governs your styling ('kicker background color' etc.)

so.. if you want to use conditional styling, you should use conditionals in your css
(putting styling in the loop is unnecessary nasty and messy )
  #3  
Old Dec 17, 2010, 07:09 PM
juggledad's Avatar
juggledad
 
20,010 posts · Mar 2009
OSX 10.6.8/10.7.3 WP 2.8.x/2.9.x/3.x Atahualpa 3.5.x/3.7.x Safari 5.x Firefox 11 XP
you have to watch switching in and out of php/html. Your code should be in The LOOP and it should replace the line
HTML Code:
<?php bfa_post_kicker('<div class="post-kicker">','</div>'); ?>
with
HTML Code:
<?php (if (in_category('red')) { ?>
<div class="post-kicker-red"> <?php } ?>
<?php bfa_post_kicker('<div class="post-kicker">','</div>'); ?>
<?php (if (in_category('red')) { ?>
</div> <?php } ?>
then in CSS Inserts you would use
HTML Code:
div.post-kicker-red .post-kicker {background: red;}
  #4  
Old Dec 18, 2010, 07:04 AM
STB
 
762 posts · Apr 2010
Quote:
Originally Posted by juggledad
you have to watch switching in and out of php/html. Your code should be in The LOOP and it should replace <...>
Although that would probably work, it is unnecessary messy.



The classes are already there in the parent div.
Thus, no need to edit your php files and add extra classes (and come to think of it, no need for conditional css even).
I would just add this css in Ata > HTML/CSS inserts:
Code:
div.category-uncategorized > div.post-kicker {display: none;}
div.category-red> div.post-kicker {background: red;}
div.category-blue> div.post-kicker {background: blue;}

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with parent category php? Please!! theadventurebite Plugins & Atahualpa 1 Jul 6, 2010 05:05 AM
Conditional PHP issue MyJourneytoMillions Center area post/pages 6 Feb 10, 2010 03:11 PM
category pages missing styling sharmtravel Header configuration & styling 0 Aug 21, 2009 06:01 AM
How do I provide a conditional Widget in the sidebars? bgt Forum How-To 1 Jun 1, 2009 02:16 PM
Styling Category Widget BigG Sidebars & Widgets 3 Apr 16, 2009 11:53 AM


All times are GMT -6. The time now is 08:32 AM.


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