I am using Redux framework option panel to handle logo on my header.
The scenario:
- Display custom logo when I upload my own logo.
- Display text logo when the custom logo not active.
- Display default logo when custom logo and text logo not active.
My code here:
<?php global $redux_demo; if ( isset($redux_demo['opt_header_logo']['url']) ){ ?>
<a href="<?php echo esc_url( home_url( '/' ) ); ?>"> <img alt="<?php echo get_bloginfo('name'); ?>" src="
<?php if( isset($redux_demo['opt_header_logo']) ){ ?>
<?php echo esc_url($redux_demo['opt_header_logo']['url']); ?>
<?php } ?>"> </a>
<?php }
else if ( isset($redux_demo['opt_header_logo']) ){ ?>
<h1> <a href="<?php echo esc_url( home_url( '/' ) ); ?>">
<?php if( isset($redux_demo['opt_header_text']) ){ ?>
<?php echo esc_html($redux_demo['opt_header_text']); ?>
<?php } ?>
</a> </h1>
<?php }
else { ?>
<img src="<?php echo esc_url( get_template_directory_uri() . '/images/logo.png' ); ?>">
<?php }
?>
These code only work for custom logo and default logo (scenario 1 and 3.) But did not work when I want to use text as logo. Really appreciate for any helps.
CodePudding user response:
try this
<?php
global $redux_demo;
if ( isset($redux_demo['opt_header_logo']['url']) && !empty($redux_demo['opt_header_logo']['url']) ){
?>
<a href="<?php echo esc_url( home_url( '/' ) ); ?>"> <img alt="<?php echo get_bloginfo('name'); ?>" src="<?php echo esc_url($redux_demo['opt_header_logo']['url']); ?>"> </a>
<?php } else if ( isset($redux_demo['opt_header_text']) && !empty($redux_demo['opt_header_text']) ){ ?>
<h1> <a href="<?php echo esc_url( home_url( '/' ) ); ?>">
<?php echo esc_html($redux_demo['opt_header_text']); ?>
</a> </h1>
<?php }else { ?>
<a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php echo esc_url( get_template_directory_uri() . '/images/logo.png' ); ?>"></a>
<?php } ?>