To override the variable directly add the fucntion print_page_title
in child theme functions.php
this should work as the parent theme uses if(!function_exists('print_page_title'))
condition to check for the function, since child theme’s function.php
is loaded first this is used instead of parent theme.
Place the following code in your child-theme’s functions.php
function print_page_title() {
global $post;
$page_title = get_the_title($page_id);
if(is_home()) {
$page_title = esc_html__('Blog','crexis');
}
if ( 'Blog' == $page_title ) {
$page_title="Resources" ;
} ?>
<h1><?php echo esc_textarea($page_title); ?></h1><?php
}
add_action( 'print_page_title', 'resources_header' );
The above doesn’t work because there is no action hook print_page_title
. It works if the code in your parent theme is like:
if(!is_front_page() && ( theme_option('header_title') != 0 '' ....//conditions) {
do_action('print_page_title');
}
add_filter( 'print_page_title', 'resources_header' );
will work if the funcion in parent theme function is like:
function print_page_title() {
global $post;
$page_title = get_the_title($page_id);
if(is_home()) {
$page_title = esc_html__('Blog','crexis');
}
$page_title = apply_filters('print_page_title',$page_title);
?>
<h1><?php echo esc_textarea($page_title); ?></h1><?php
}