Created
March 6, 2019 15:01
-
-
Save moxdev/906be7329317129efe8f3cce49ad7246 to your computer and use it in GitHub Desktop.
Page header SEO ACF #wp #acf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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