Hooks/Action Reference/builder add title

From IThemes Codex
Revision as of 10:18, November 15, 2011 by Gaarai (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Update

This action hook has been superseded by the builder_filter_title filter. While the action will still work, using the filter is recommended.

Description

This action hook is called in the Builder core's header.php template file inside the head tag. By default, the builder_add_title function is attached to this action, which outputs a title tag specific to the current page view.

Possible Uses

By unregistering existing hooked functions and adding your own, you can supply your own custom page title function. By doing this rather than modifying the header.php file, your modification will work regardless of child theme used. This is exactly how the Builder SEO plugin is able to replace Builder's default title.

Parameters

None

Example Use

This example is extremely simple and simply replaces each page's title with "Custom Title".

<?php
    // Function to display the custom title
    function custom_replace_builder_page_title() {
        echo "<title>Custom Title</title>\n";
    }

    // Function to replace the existing builder_add_title handler with the new one
    function custom_replace_builder_page_title_handler() {
        remove_all_actions( 'builder_add_title' );
        add_action( 'builder_add_title', 'custom_replace_builder_page_title' );
    }

    // Hook into the template_redirect action with a late priority to ensure that
    // this code runs after the Builder SEO plugin's hook to handle the title
    add_action( 'template_redirect', 'custom_replace_builder_page_title_handler', 20 );
?>

Back to Builder Hooks

Personal tools
Namespaces
Variants
Actions
iThemes Codex
Codex Navigation
Toolbox