homepage Welcome to WebmasterWorld Guest from 54.226.173.169
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP / WordPress
Help with the IF statement
giggle




msg:4421646
 10:48 am on Feb 25, 2012 (gmt 0)

Hi

I have a piece of code in a WordPress theme that I'd like some help with, please.


<?php if (is_page('ThisPage')) { include (TEMPLATEPATH . '/HeaderResults.php'); } else { wp_get_header(); } ?>

<div class="art-contentLayout">
<?php include (TEMPLATEPATH . '/sidebar1.php');?>


I would only like the last two lines executed if the page selected is not ThisPage. I've searched the web and tried all sorts of variations but I cannot get any to work. Help!

Also, how do I substring a page name to see if it starts with the string "STARTSWITHTHIS"?

Thanks

Mick

 

RonPK




msg:4422235
 1:16 pm on Feb 27, 2012 (gmt 0)

You'll need to jump out of PHP parsing at the right spot in the else condition:

<?php
if (is_page('ThisPage')) {
include (TEMPLATEPATH . '/HeaderResults.php');
} else {
wp_get_header();
?>
<div class="art-contentLayout">
<?php
include (TEMPLATEPATH . '/sidebar1.php');
}
?>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved