In your child theme’s folder, if you already got a functions.php
, just put the code in below. If you haven’t got one yet, just create a blank file and name it functions.php
, at the very top put this in <?php
and do not put the closing ?>
in the bottom.
function pinboard_doc_title( $doc_title ) {
global $page, $paged;
$doc_title = str_replace( '?', '', $doc_title );
$site_description = get_bloginfo( 'description', 'display' );
$separator = '#124';
if ( is_singular() ) {
if( is_page() )
$doc_title .= ' &' . $separator . '; ';
$doc_title .= get_bloginfo( 'name' );
if( is_front_page() )
$doc_title .= get_the_title();
if ( $paged >= 2 || $page >= 2 )
$doc_title .= ', ' . __( 'Page', 'pinboard' ) . ' ' . max( $paged, $page );
} else {
if( ! is_home() )
$doc_title .= ' &' . $separator . '; ';
$doc_title .= get_bloginfo( 'name' );
if ( $paged >= 2 || $page >= 2 )
$doc_title .= ', ' . __( 'Page', 'pinboard' ) . ' ' . max( $paged, $page );
}
if ( ( is_home() ) && $site_description )
$doc_title .= ' &' . $separator . '; ' . $site_description;
return $doc_title;
}
The function above is the same exact one from the parent’s with 3 lines added, you will notice the is_page()
block here.
if( is_page() )
$doc_title .= ' &' . $separator . '; ';
$doc_title .= get_bloginfo( 'name' );
Now you will get Page Title | Site Title on page.
if you want the same thing for post to, just put in OR ( || ) like this
if( is_page() || is_single() )
$doc_title .= ' &' . $separator . '; ';
$doc_title .= get_bloginfo( 'name' );