[thelist] [WD]: WordPress - PHP to include <div> based on page being displayed

Bob Meetin bobm at dottedi.biz
Wed Jul 8 09:44:41 CDT 2009

matt1027 wrote:
> At 01:12 AM 7/8/2009, you wrote:
>>>  So I tried changing the !==
>>> and the != to just = but that didn't work.
>> Checking for equality is == (two equals signs [and sometimes three]),
>> not = (one equals sign).
> Thank you for the clarifying that.  It still doesn't work and I think 
> it must be something about the way PHP in the WordPress is working 
> with Apache to specify what the PHP_SELF or SCRIPT_NAME is.
> In case anyone sees this message without the original, both of the 
> following work just fine with my regular website but I haven't been 
> able to get them to work with a WordPress blog.
>> <?php if ($_SERVER['SCRIPT_NAME'] !== '/pages/meeting.php'): ?>
>> <!-- stuff here -->
>> <?php endIf; ?>
Whether you're writing custom CMS or in my case, working with Joomla, 
you can commonly set up a test against the ID or filename itself.  I am 
not sure about PHP_SELF and how Wordpress works in this case.

If I need to add a custom JavaScript or CSS element (perhaps in the 
head) to only the about page or several pages, I set up an include file 
and if it passes the test, the text is included. You can do similar to 
exclude opening and closing <div> elements.

if ( $ID != "13" && $ID !="77" && $filename != "whatever.php" ) // 
various test types or use OR (||)
{ ?>
<div>left column etc</div>
<?php }

These tests work with != and == rather than !== (three) which I didn't 
know about.  I will do this in the function that creates the index.php 
and occasionally locate and write to the module construct itself.  This 
might not be what you're asking.


More information about the thelist mailing list