• Resolved hrcwebmaster

    (@hrcwebmaster)


    Hi there,
    I would like to “switch” my header for different pages I have in my Web site. Since this would apply to about 50 different pages, I was hoping to use either the featured image or custom fields to “switch” from my default header to the image of my choosing. I would appreciate any advice and code! I’m very new to WordPress and PHP, but catching on quickly!

Viewing 1 replies (of 1 total)
  • Thread Starter hrcwebmaster

    (@hrcwebmaster)

    Ok I figured it out. In header.php I added this code:

    <?php
    
    // Check to see if the header image has been removed
    
    if (get_post_meta( $post->ID, 'custom-field', true )) : ?>
    
    <h1 id="site-logo">
    
    <a href="
    <?php echo esc_url( home_url( '/' ) ); ?>" title="
    <?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
    
    <img src="<?php echo get_post_meta( $post->ID, 'custom-field', true ); ?>" />
    
    <?php else : ?> 
    
    <img src="<?php header_image(); ?>" />
    
    <?php endif; ?>

    You just need to replace custom-field with the name of your custom field.

Viewing 1 replies (of 1 total)
  • The topic ‘[Theme: Catchbox] Dynamic headers/featured image as header’ is closed to new replies.