Skip to content

Instantly share code, notes, and snippets.

@moxdev
Created March 6, 2019 15:01
Show Gist options
  • Save moxdev/906be7329317129efe8f3cce49ad7246 to your computer and use it in GitHub Desktop.
Save moxdev/906be7329317129efe8f3cce49ad7246 to your computer and use it in GitHub Desktop.
Page header SEO ACF #wp #acf
<?php
// Page Titles.
if ( ! function_exists( 'slug_page_titles' ) ) :
/**
* Output custom page titles for SEO
*
* @return void
*/
function slug_page_titles() {
if ( function_exists( 'get_field' ) ) {
$on_page_title = get_field( 'on_page_title' );
if ( $on_page_title ) {
?>
<header class="entry-header">
<h1 class="entry-title">
<?php
echo wp_kses(
$on_page_title,
array(
'span' => array(),
'em' => array(),
'strong' => array(),
'br' => array(),
'sup' => array(),
)
);
?>
</h1>
</header><!-- .entry-header -->
<?php
} else {
?>
<header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</header><!-- .entry-header -->
<?php
}
}
}
endif;
// put this in content-page.php or wherever you need a page title
< ? php slug_page_titles(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment