Skip to content

Instantly share code, notes, and snippets.

@WPprodigy
Created January 19, 2016 17:14
Show Gist options
  • Save WPprodigy/816ba1827edafe29568d to your computer and use it in GitHub Desktop.
Save WPprodigy/816ba1827edafe29568d to your computer and use it in GitHub Desktop.
Add subtitle field to Storefront
<?php
// Display subtitle after the header for posts and pages
add_action( 'storefront_single_post', 'storefront_add_subtitle_after_header', 15 );
add_action( 'storefront_page', 'storefront_add_subtitle_after_header', 15 );
function storefront_add_subtitle_after_header() {
the_subtitle( "<h2 class='subtitle'>", "</h2>" );
}
// Display subtitle in the header for posts
function storefront_post_header() { ?>
<header class="entry-header">
<?php
if ( is_single() ) {
storefront_posted_on();
the_title( '<h1 class="entry-title" itemprop="name headline">', '</h1>' );
the_subtitle( "<h2 class='subtitle'>", "</h2>" );
} else {
if ( 'post' == get_post_type() ) {
storefront_posted_on();
}
the_title( sprintf( '<h1 class="entry-title" itemprop="name headline"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h1>' );
the_subtitle( "<h2 class='subtitle'>", "</h2>" );
}
?>
</header><!-- .entry-header -->
<?php
}
// Display subtitle in the header for pages
function storefront_page_header() { ?>
<header class="entry-header">
<?php
storefront_post_thumbnail( 'full' );
the_title( '<h1 class="entry-title" itemprop="name">', '</h1>' );
the_subtitle( "<h2 class='subtitle'>", "</h2>" );
?>
</header><!-- .entry-header -->
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment