I am trying to change the h1
tag in the head of my child theme from "Blog" to "Resources". The parent theme enqueues files with require_once
and get_template_directory
so it's very difficult to overwrite file through child theming. If anyone has a solution to that it would be great, but if not I thought I would just attempt to modify the variable in my functions file instead.
The parent theme uses this code basically.
function print_page_title() {
global $post;
$page_title = get_the_title($page_id);
if(is_home()) {
$page_title = esc_html__('Blog','crexis');
} ?>
<h1><?php echo esc_textarea($page_title); ?></h1><?php
}
(For testing purposes) if I modify it this way it works:
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
}
But this (and other variations I've tried) doesn't work if I put the following in my child's functions.php:
function resources_header() {
global $page_title;
if ( 'Blog' == $page_title ) {
$page_title = 'Resources' ;
}
}
add_action( 'print_page_title', 'resources_header' );
I've also tried add_filter
instead of add_action
OR after_setup_theme
instead of print_page_title
. What am I doing wrong?
print_page_title
used in parent theme and how? Is it hooked to any action? – bravokeyl Sep 12 '16 at 4:35if(!function_exists('print_page_title')) { function print_page_title() {...}
. Found in /framework/functions/header-functions.php. I can't find another reference to it anywhere. – Heather Sep 12 '16 at 4:39if(!is_front_page() && ( theme_option('header_title') != 0 || theme_option('header_title') == '') && get_post_meta(get_the_ID(), 'page_header', true) != 'no-header' && !is_page_template('template-onepager.php') || is_search() && theme_option('header_title') != 0) { print_page_title(); }
– Heather Sep 12 '16 at 4:40