Change the body class name for a WordPress template page
Article- Posted at
- No comment for this post
- Permalink
- wordpress
Open the “functions.php” and add this following code for renaming page-template-template-about-php to page-template-about.
// Rename '.page-template-template-name-php' to '.page-template-name'.
function rename_template_body_class( $classes ) {
foreach ( $classes as $k => $v ) {
if ( substr($v, 0, 22) == 'page-template-template' )
$classes[ $k ] = 'page-' . substr( $v, 14, -4 );
}
return $classes;
}
add_filter( 'body_class', 'rename_template_body_class' );
Discussion No comment - RSS feed