Hi all
I'm trying to spit out a specific //title// in the //head// for Pages based on
1) Whether the page is a specific page I want a custom title for
2) Whether the page is ANY OTHER PAGE except that specific one
Here's what I have so far, that isn't working ("15291" is the Page ID number):
<?php if(is_page('15291')) {
This is the title for the SPECIFIC PAGE
}
else(is_page()) {
This is the title for ANY OTHER PAGE
}
?>
Any idea why this isn't working? What do I need to change to get the required result?
Thanks!
Try this:
<?php if( is_page('15291') ) { ?>
This is the title for the SPECIFIC PAGE
<?php } elseif( is_page() && !is_page('15291') ) { ?>
This is the title for ANY OTHER PAGE
<?php } ?>
That totally looks like it should work, actually.
Unfortunately, it doesn't. I'm getting this error:
Parse error: syntax error, unexpected '{' in /home/public_html/wp/wp-content/themes/theme-name/header.php on line 20
<?php if( is_page('2') ) {
?>
<title>This is the title for the SPECIFIC PAGE</title>
<?php
}
if ( is_page() && !is_page('2') ) {
?>
<title>This is the title for ANY OTHER PAGE</title>
<?php }
?>
that works. change the page number, obviously.
Made a mistake (!!), using else instead of elseif. Fixed it in code above. whooami's stuff will do as well. ;)
YES! Success!
Exactly what I needed. Thanks so much for your prompt response.
In case you were wondering, I needed this function because I'm using a static page as my homepage, and I didn't want it to have the same //title// structure as every other page -- so I set the //title// page ID to its own unique title.
Thanks again!