Syntax Error in Conditional Custom Field Code
-
Hi everyone,
I’m trying to have a bit of custom text (from a custom field) display, and if a page doesn’t have that custom field, than have a default/standby bit of text appear. Here is the code I’m using, and I’m receiving a “unexpected T_ENDIF” syntax error. I’m a true beginner in PHP, so if it’s something obviously wrong (which I’m sure it is), please be kind 🙂
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php $pageHeader=get_post_meta($post->ID, 'pageHeader', true); ?> <?php if ( $pageHeader ) { ?> <!-- with custom page header --> <?php echo $pageHeader; ?> <?php } else { ?> <!-- without custom page header --> Sample code <?php endif; ?> <?php if ( has_post_thumbnail() ) { the_post_thumbnail(); } ?> <h1><?php the_title(); ?></h1> <?php the_content(); ?> <?php endwhile; endif; ?>Any ideas? Any help is greatly appreciated.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Syntax Error in Conditional Custom Field Code’ is closed to new replies.