
Originally Posted by
DarkOcean
<title><?php if( $post ) { echo $post->post_title; }?></title>
I just want to know what the correct way is to add the static text: '>> Worlds leading school of photography.'
...just add the static text:
PHP Code:
<title><?php if( $post ) { echo $post->post_title; }?> >> Worlds leading school of photography</title>
however, it would be more robust like so:
PHP Code:
<?php
// start
$title = '<title>';
// check the actual property you're trying to use, not just the object
// also, the way you do it above will still cause an error if $post does not exist
// in the end, this:
// if( $post ){ echo $post->post_title; }
// is no different than:
// echo $post->post_title;
// except that you have _two_ opportunities to run into problems.
if( !empty( $post->post_title ) ){ $title .= $post->post_title; }
// add the static part, and finish
$title .= ' >> Worlds leading school of photography</title>';
// when you're ready...
print $title;
also,
Please use the forum's bbcode tags and indent your code to make it more readable:
for php code............[php] <?php /* code goes here */ ?> [/php]
for html...............[html] <!-- markup goes here -->.....[/html]
for js/css/other.......[code] code goes here................[/code]
Bookmarks