Updated on May 24, 2017
In the comments section of How to display CPT archive headline/intro inside the page header in Showcase Pro article a user asked:
Hi Sridhar, Is it possible to do something similar to this with all the pages? Instead of showing the page title, you can add a custom headline and sub-headline? The same as the home page.
In Showcase Pro, title appears inside the Page Header on Pages like this (when the Page has a featured image):
We can add two custom fields called say Page Headline and Page Subheading using ACF plugin, attach these to Pages and when these are filled,
display them on the frontend.
We shall set this up such that if the headline is left empty, the standard Page title will appear in its place like before. Subheading is optional as well. If present, it will appear beneath the title/headline.
Tested in Showcase Pro v2.0.0
Step 1
Install and active Advanced Custom Fields.
Import this field group or manually add a field group named say, Page Meta
having the two text fields.
Step 2
Edit your Page(s), populate the two custom fields and update.
Step 3
In functions.php replace
$title = the_title( '<h1>', '</h1>', false );
with
To view the full content, please sign up for the membership.
Already a member? Log in below or here.
Thank you so much, this is fantastic!
How would I implement something like this on posts?
Try this Mike:
In Step 1’s Page Meta ACF field group, add another “or” rule group and set it to appear on “post” type as well.
In Step 3, change
[php]if ( is_singular( ‘page’ ) ) {[/php]
to
[php]if ( is_singular( array( ‘page’, ‘post’ ) ) ) {[/php]
How would I implement this on category archives as well?
Have got the ACF field displaying on the “Edit Category” pages by adding the rule “or Taxonomy Term is equal to Categories”. I can’t get it to display on the front end though.
Worked this one out. Used the in-built Genesis category archive settings and genesis_do_taxonomy_title_description().
Changed:
remove_action( ‘genesis_before_loop’, ‘genesis_do_taxonomy_title_description’, 15 );
echo single_term_title( '<h1>', '</h1>', true );
/**
* This is a weird hack to fix the non-closing h1 above, for some reason
* it's including the paragraph below, so I'm echoing a closing h1 tag.
*/
echo '</h1>';
echo term_description();
To:
remove_action( ‘genesis_before_loop’, ‘genesis_do_taxonomy_title_description’, 15 );
genesis_do_taxonomy_title_description();
echo term_description();
Could you post the info to integrate this in the newest version of Showcase Pro?
Here’s the single.php below:
<?php
/**
* Showcase Pro
*
* This file edits the single template in the Showcase Pro Theme.
*
* @package Showcase
* @author Bloom
* @license GPL-2.0+
* @link http://my.studiopress.com/themes/showcase/
*/
// Add page header body class to the head
add_filter( ‘body_class’, ‘showcase_single_page_header_body_class’ );
function showcase_single_page_header_body_class( $classes ) {
if( has_post_thumbnail() )
$classes[] = 'with-page-header';
return $classes;
}
// Add page header
add_action( ‘genesis_after_header’, ‘showcase_single_page_header’, 8 );
function showcase_single_page_header() {
$output = false;
$image = get_post_thumbnail_id();
if( $image ) {
// Remove the title since we'll add it later
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
$image = wp_get_attachment_image_src( $image, 'showcase_hero' );
$background_image_class = 'with-background-image';
$title = the_title( '<h1>', '</h1>', false );
$output .= '';
$output .= '' . $title . '';
$output .= '</div></div>';
}
if( $output )
echo $output;
}
genesis();
I’ve updated the tutorial for the current latest Showcase Pro.
Thank you so much Sridhar for the swift update. Hell yeah!
Going to work on this now.
Thank you again for the great tutorials!!!
When I do this, it causes the titles of the individual blogs listed on the page to go away.
Any ideas on what’s causing this?
buildlouisville.com/blog
I see the posts’ titles fine at http://buildlouisville.com/blog/. Can you elaborate?
Yes – I was able to fix it by removing the following line in the Showcase Pro functions.php file …
// Remove the title since we’ll add it later
remove_action( ‘genesis_entry_header’, ‘genesis_do_post_title’ );
Thank you for the helpful, updated tutorial.