DaveSandwich Posted October 22, 2017 Share Posted October 22, 2017 I have added the following code to my functions.php but its not changing the page name. I have both file name and template name set to "page-FullWidthdynamic.php" I thought "is_page_template" referred to the template name rather than the file name within the themes/child themes folder. Template Name: /** * Template Name: page-FullWidthdynamic.php * @package WordPress * @subpackage Themetemplate */ functions.php code: function filter_wp_title( $title ) { // Change page title if page template is: if ( is_page_template( 'page-FullWidthdynamic.php' ) ) { return 'life is good'; } // Otherwise, don't modify the document title return $title; add_filter( 'wp_title', 'filter_wp_title' ); } Quote Link to comment https://forums.phpfreaks.com/topic/305423-dynamically-change-wordpress-title-based-on-page-template/ Share on other sites More sharing options...
phpmillion Posted October 23, 2017 Share Posted October 23, 2017 Maybe your page-FullWidthdynamic.php file is located in some subdirectory inside your template directory? If that's the case, you need to include subdirectory name too. It's also hard to tell where and how you use the code, but be aware that this function doesn't work well inside loop. Quote Link to comment https://forums.phpfreaks.com/topic/305423-dynamically-change-wordpress-title-based-on-page-template/#findComment-1552963 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.