Archive

Archive for December, 2012

WordPress Architecture theme: show parent page title

December 26th, 2012 No comments

The other day I had a customer who wanted to use the Architecture theme of Goodlayers. On subpages it would show the title of that page while it was better for the customer to show the parent page title. So I modified the theme a bit.

In “/include/plugin/page-item.php” on line 88 you have the function print_page_header

// Print page header
function print_page_header( $header, $bgid = '' ){
if( !empty($bgid) ){
$thumbnail = wp_get_attachment_image_src( $bgid , 'full' );
echo '<div class="page-header-wrapper" style="background: url('' . $thumbnail[0] . '') center 0px no-repeat; ">';
}else{
echo '<div class="page-header-wrapper">';
}
echo '<div class="page-header-inner-container container">';
echo '<div class="page-header-inner-wrapper row">';
echo '<h1 class="page-header-title">' . $header . '</h1>';
echo '</div>';
echo '</div>'; // page-header-inner-container

echo '</div>'; // page header wrapper
}

Replace it by this

// Print page header
function print_page_header( $header, $bgid = '' ){

global $post;

$custom_show_parent_title = get_post_meta( $post->ID , "page-option-show-parent-title", true);
$custom_header = $header;
If (strtolower($custom_show_parent_title) == 'yes'){
$t_custom_header = get_the_title( $post->post_parent );
If (!empty($t_custom_header)){ $custom_header = $t_custom_header; }
}

if( !empty($bgid) ){
$thumbnail = wp_get_attachment_image_src( $bgid , 'full' );
echo '<div class="page-header-wrapper" style="background: url('' . $thumbnail[0] . '') center 0px no-repeat; ">';
}else{
echo '<div class="page-header-wrapper">';
}
echo '<div class="page-header-inner-container container">';
echo '<div class="page-header-inner-wrapper row">';
echo '<h1 class="page-header-title">' . $custom_header . '</h1>';

echo '</div>';
echo '</div>'; // page-header-inner-container

echo '</div>'; // page header wrapper

}

Then in your page (admin interface) add a new custom field called “page-option-show-parent-title” with the value “yes”. Check the WordPress codex if you need help with that.

PDF version of the code-snippets: wordpress-goodlayers-architecture-theme-show_parent_page_title-blog.elmore.be