Change Genesis <title> Tag from Page Template

I have made a page template for a Genesis theme in which I want to change the <title> tag but I can’t find any API reference or example to do this.

Does anyone have any idea how to do this?

Related posts

3 comments

  1. Try

    add_filter('wp_title', 'my_custom_title');
    function my_custom_title($title) {
        return 'My Custom Title';
    }
    

    Check genesis/lib/structure/header.php to see how Genesis does it.

  2. I don’t know about any Genisis-specific way of doing this, but you can change the page title though the wp_title filter.

    function foo_template_title( $title ) {
        return 'Foo Template';
    }
    add_filter( 'wp_title', 'foo_template_title' );
    

    The next step is to check if the current page uses the Foo Template page template. Remember to replace foo_template.php with the filename of your page template:

    function foo_template_title( $title ) {
        if ( is_page_template( 'foo_template.php' )
            return 'Foo Template';
        else
            return $title;
    }
    add_filter( 'wp_title', 'foo_template_title' );
    

    See the WordPress Codex for more information on the is_page_template() function and the wp_title filter.

Comments are closed.