• Resolved brocoli

    (@brocoli)


    I want the header (custom logo image) to change depending on which page you are in by using conditional tags but i don’t know where to insert the script. I am using a modified version of the snippet provided here

    <?php
    
    if ( is_page('about') || $post->post_parent == '2' ) {
        // the page is "About", or the parent of the page is "About"
        $bannerimg = 'about.jpg';
    
    } elseif ( is_page('learning') || $post->post_parent == '56' ) {
        $bannerimg = 'teaching.jpg';
    
    } elseif ( is_page('admissions') || $post->post_parent == '15' ) {
        $bannerimg = 'admissions.jpg';
    
    } else {
        $bannerimg = 'home.jpg'; // just in case we are at an unclassified page, perhaps the home page
    }	
    
    ?>

    My intention is to make the header according to the page you are in

Viewing 2 replies - 1 through 2 (of 2 total)
  • For the script you have above, you can turn that into a function and insert it in functions.php.

    Thread Starter brocoli

    (@brocoli)

    Solved the problem
    in the core.php file located in the lib folder i replaced the following code in line 451

    if($options['logo']) // logo image?
        $output .= '<a href="'.$siteurl.'"><img src="'.$options['logo'].'" title="'.$sitename.'" '.$size.' alt="'.$sitename.'" /></a>';
      else
        $output .= '<a href="'.$siteurl.'">'.$sitename.'</a>';
      $output .= '</'.$tag.'>';
      echo apply_filters('mystique_logo', $output);
    }

    by the following code depending on the page number overrides the custom logo image uploaded in the mystique settings by the one of your choice

    if ( is_page(array (6,9,106,11,117,123,125,127,13,15,17)) || $post->post_parent == '6' ) {
        // the page is "6,9,106,11,etc...", or the parent of the page is "6"
        $output .= '<a href="'.$siteurl.'"><img src="link to the image" title="'.$sitename.'" '.$size.' alt="'.$sitename.'" /></a>';
    
    } elseif ( is_page(array(22,24,26,28)) || $post->post_parent == '22' ) {
    	   $output .= '<a href="'.$siteurl.'"><img src="link" title="'.$sitename.'" '.$size.' alt="'.$sitename.'" /></a>';
    
    } elseif ( is_page(array (32,34,36,38)) || $post->post_parent == '32' ) {
           $output .= '<a href="'.$siteurl.'"><img src="link" title="'.$sitename.'" '.$size.' alt="'.$sitename.'" /></a>';
    
    } elseif ( is_page(array (44,46,48,50)) || $post->post_parent == '44' ) {
           $output .= '<a href="'.$siteurl.'"><img src="link" title="'.$sitename.'" '.$size.' alt="'.$sitename.'" /></a>';
    
    } elseif ( is_page(array (54,56,58,60,62)) || $post->post_parent == '54' ) {
          $output .= '<a href="'.$siteurl.'"><img src="link" title="'.$sitename.'" '.$size.' alt="'.$sitename.'" /></a>';;
    
    } elseif ( is_page(array (66,68,70,72,74)) || $post->post_parent == '66' ) {
        $output .= '<a href="'.$siteurl.'"><img src="link" title="'.$sitename.'" '.$size.' alt="'.$sitename.'" /></a>';
    
    } elseif ( is_page(array (79,81,83)) || $post->post_parent == '79' ) {
           $output .= '<a href="'.$siteurl.'"><img src="link" title="'.$sitename.'" '.$size.' alt="'.$sitename.'" /></a>';
    
    } elseif ($options['logo']) // logo image?
        $output .= '<a href="'.$siteurl.'"><img src="'.$options['logo'].'" title="'.$sitename.'" '.$size.' alt="'.$sitename.'" /></a>';
      else
        $output .= '<a href="'.$siteurl.'">'.$sitename.'</a>';
      $output .= '</'.$tag.'>';
      echo apply_filters('mystique_logo', $output);
    }

    the last part trows back the default image uploaded if none of the pages match.

    Hope this helps someone

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Mystique Custom Header in pages’ is closed to new replies.