WordPress.org

Forums

twenty twelve custom page template (3 posts)

  1. p_getchell
    Member
    Posted 2 years ago #

    Twenty-twelve child theme
    site = pinetreeschool.org
    A series of pages on this site need their own look so I am working on a custom page template to use when I create each page. I would like the pages in the series to have identical headers and header images unique to this series. I've manged this for a single page based on the default template using a conditional statement (pinetreeschool.org/?page_id=325) in page.php. Can I automate this by using a custom template?

  2. Michael
    Forum Moderator
    Posted 2 years ago #

    possibly try working with the conditional tag http://codex.wordpress.org/Function_Reference/is_page_template

  3. p_getchell
    Member
    Posted 2 years ago #

    Thank-you alchymyth. My 1st clumsy attempt seems to work. Unless you see anything else, I shall mark this resolved.

    /*the following conditional statements test a page to determine which header to use. The 1st condition, if true, displays the reading header image. If false, (elseif) it tests for a 2nd condition which also displays the reading header image. If 2nd condition is false, it displays the default custom header image which we use for all other pages on the site*/
    		<?php $header_image = get_header_image();
    		if (is_page('Read Every Day')) :
    		echo '<a href="' . esc_url( home_url( '/' ) ) . '"><img class="header-image" src="http://www.pinetreeschool.org/wp-content/uploads/2014/03/headerreading-copy.jpg" alt="" /></a>';elseif (is_page_template('bookreview.php')) :
    		echo '<a href="' . esc_url( home_url( '/' ) ) . '"><img class="header-image" src="http://www.pinetreeschool.org/wp-content/uploads/2014/03/headerreading-copy.jpg" alt="" /></a>';
    		elseif( ! empty( $header_image ) ) : ?>
    			<a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php echo esc_url( $header_image ); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" /></a>
    		<?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic