I'd do this :-
TaPHP Code:
<?php $title = wp_title(); ?>
<?php if (empty($title)) { ?>
some html
<?php } else { ?>
some html
<?php } ?>
Barry
OK I am a windows programmer and am trying to get my head around the basics of PHP so I can make a few changes to Wordpress blogs.
I am pulling my hair out with the following as it doesn't work and just gives me a blank page:
<?php $title = wp_title(); ?>
<?php if (empty($title)) ?>
some html
<?php else : ?>
some html
<?php endif; ?>
I'm sure it's a syntactical error?
If anyone can let me know what I am doing wrong it would be much appreciated :-)
I'd do this :-
TaPHP Code:
<?php $title = wp_title(); ?>
<?php if (empty($title)) { ?>
some html
<?php } else { ?>
some html
<?php } ?>
Barry
No problems
Ta
Baz
Barry's answer works but to fix your problem you were just missing a colon after the last bracket:
<?php if (empty($title)) : ?>
It's just the alternate syntax for the curly brackets:
if ( blah )
{
// Your code
}
or
if ( blah ) :
// Your code
endif;
I'm from a C/C++ background and I prefer the former but it's easier to use the latter when combining it with HTML.
Cheers,
Marc
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks