Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Genesis Custom SEO Title
<?php
/**
* Genesis Custom SEO Title
*
* @author Edwin Velez (https://edwinvelez.net)
* @link https://edwinvelez.net/genesis-custom-seo-title/
*/
add_filter( 'genesis_seo_title', 'ev_custom_seo_title', 10, 3 );
/**
* Modify title for SEO title.
*
* @param string $title The SEO title.
* @param string $inside The inner portion of the SEO title.
* @param string $wrap The html element to wrap the title in.
*
* @see genesis_seo_site_title();
*
* @return string|string[]
*/
function ev_custom_seo_title( $title, $inside, $wrap ) {
/**
* Apply HTML H1 tag on all pages rather than just home page which is default. Optionally, rather than modify HTML
* title output can be changed just the same.
*
* NOTE: $tile contains HTML. To see actual HTML contents use esc_html().
*
* Conditional filtering can be set with Genesis genesis_is_root_page() function or with WordPress is_front_page()
* function.
*/
// str_replace() works because start of esc_html($title) is either HTML tag opening with "<p" or "<h1".
$title = str_replace( 'p', 'h1', $title );
return $title;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.