I’m trying to create a conditional statement to change the href of my header logo according to a certain page number. For example, on page (29) I want the logo to direct to “facebook” and on all other pages I want it to direct to the “home page”.
<div class="logo_container">
<span class="logo_helper"></span>
<?php
if( is_page(29) ) {
<a href="https://www.facebook.com">
<img src="<?php echo esc_attr( $logo ); ?>"
alt="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>"
id="logo"
data-height-percentage="<?php echo esc_attr( et_get_option( 'logo_height', '54' ) ); ?>" />
</a>
} else {
<a href="<?php echo esc_url( home_url( '/' ) ); ?>">
<img src = "<? php echo esc_attr ($ logo);?>"
alt = "<? php echo esc_attr ( get_bloginfo ('name')); ?> "
id =" logo "
data-height-percentage =" <? php echo esc_attr (et_get_option ('logo_height', '54')); ?> "/>
</a>
}
?>
</div>
I get this error
(( ! ) Parse error: syntax error, unexpected ‘
<
‘ in I:wampwwwtestnomwp-contentthemesdivi-childheader.php on line 244)
3
Answers
You’re not closing and opening php. I think I’ve got it property edited below:
You need to close the php tags at the final of php code. Like in the if.
For my knoledge you cannot use php bloques inside another php bloques.
So when you do the if else echo all html instead.