Problem with conditionals and CSS

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jameskyle
Forum Newbie
Posts: 1
Joined: Fri Dec 10, 2010 7:01 am

Problem with conditionals and CSS

Post by jameskyle »

Hi, I'm new to PHP and new to these forums. I know a decent amount of Actionscript and a little C++ but I'm having difficulty with something I'm working on in PHP. It's probably very simple but I've been struggling with it for a week or two with no luck.

What I'm trying to do it to create a wordpress child theme that uses the wordpress theme "Thematic" as its parent. The theme uses a functions.php file to which I can add little bits of code to alter the appearance of the pages. The theme should display the single post and pages as background-image:none, with all other areas of the theme displaying background-image: featured-image(). This latter part clearly doesn't work as CSS, hence the reason why I'm turning to PHP.

You can see my working so far here. My current conditional statement doesn't seem to work, always resorting to the else:

Code: Select all

if (is_single() || is_page()) {
echo "single post or page";
} else {
echo "post background is featured image";
}
In case it's relevant here's the full content of my functions.php file.

Code: Select all

<?php

// Remove default Thematic actions
function remove_thematic_actions() {
    remove_action('thematic_header','thematic_access',9);
}
add_action('init','remove_thematic_actions');

add_action('thematic_aboveheader','thematic_access',9);
	
	if (is_single() || is_page()) {
		echo "single post or page";
	} else {
		echo "post background is featured image";
	}
?>
If anyone could advise me as to where I'm going wrong or provide information or links I'd greatly appreciate it. PHP is something I'd love to get into.
Post Reply