WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to use existing hook in twentytwelve to all theme of wordpress? (3 posts)

  1. viky081
    Member
    Posted 9 months ago #

    I Recently tried to read the tutorial for wp_footer and also twentytwelve_credits for creating a sample wordpress plugins.
    wp_footer hook to display the footer beneath the page area.
    twentytwelve_credits hook display the footer in the page footer on a white background.
    **For Example:**
    I tried this code to show the footer with custom message.

    [ Moderator note: please wrap code or log lines in backticks or use the code button. ]

    <?php
        function your_function() {
            echo '<p>This is inserted at the bottom</p>';
        }
        add_action('wp_footer', 'your_function');
        ?>

    I tried this code after switching a theme to twenty twelve.

    <?php
        function your_function() {
            echo '<p>This is inserted at the bottom</p>';
        }
        add_action('twentytwelve_credits', 'your_function');
        ?>

    I find the difference when using different hooks. wp_footer hook is working for all themes but it is in bottom of the site. twentytwelve_credits is working for the twentytwelve theme only. I beleive twentytwelve_credits is the efficient way rather than wp_footer. but its hard to change the hook for every theme. I am not sure is the way to show of the footer with every theme with twentytwelve_credits. Any Possibilities like do_action('twentytwelve_credits');.
    Any Suggestion would be great.

  2. You can't use Twenty Twelve specific or any theme specific hooks in other themes.

    I beleive twentytwelve_credits is the efficient way rather than wp_footer. but its hard to change the hook for every theme.

    It's not really more efficient exactly. If you are making your own theme or modifying a theme then having something like twentytwelve_credits is convenient. But wp_footer does work, you just have to possibly do more work to get the output styled the way you really want.

  3. viky081
    Member
    Posted 9 months ago #

    Ok thanks for Spending Valuable Time.

Reply

You must log in to post.

About this Topic