functions.php – am I doing it right?
-
I am a PHP novice and have managed to do some basic customization using functions.php without breaking anything, but I feel like I’m missing something. Would someone be so kind as to tell me if there is a better way to approach this situation so I can better understand how to apply it to other filters?
I wanted to change the 404 page header from “Ooops” to “Oops”. The following function in functions.php of my child theme:
add_filter('tc_404_header_content', 'tc_404_new'); function tc_404_new(){ echo '<header class="entry-header"> <h1 class="entry-title">Oops, page not found</h1> <hr class="featurette-divider __before_content"> </header>'; }
correctly replaces the below text generated in class-content-headings.php. I have archive icons disabled.
‘if ( is_404() ) {
$header_class = ‘entry-header’;
$content = sprintf(‘<h1 class=”entry-title %1$s”>%2$s</h1>’,
apply_filters( ‘tc_archive_icon’, ” ),
apply_filters( ‘tc_404_title’ , __( ‘Ooops, page not found’ , ‘customizr’ ) )
);
$content = apply_filters( ‘tc_404_header_content’, $content );
}’The reason I think I did something wrong is I had to manually type oout the HTML code for the header tags and <hr> featurette-divider tag, which were previously automatically generated. I think maybe I don’t fully understand the role of the second parameter in apply_filters. What does
,'customizr')
mean in this context? Is it a defined variable somewhere?Is there another, better way to make this sort of change in functions.php?
Thanks for any insights!
- The topic ‘functions.php – am I doing it right?’ is closed to new replies.