Easy Way To Add Content Using Woo Themes Hook Manager

Woo themes offer a great feature called Hook Manager which allows you to add HTML, text or even short-codes to any location there’s a hook. Normally with most other themes you would need to write some code and add it to your themes functions.php file.

Not if you’re using a Woo Theme.

Lets take a closer look at the Hook Manager and see how it works:

Hook Manager for Woo Themes

You’ll see five tabs on the left hand side which are the different sections of your website. Each section offers a range of hooks where you can add content simply by pasting it into the correct box.

  1. Header Hooks
  2. Main Hooks
  3. Post Hooks
  4. Footer Hooks
  5. WordPress Hooks

Example: If you wanted to add a banner or line or two of text/html to the end of every post, you would click the Post tab on the left and look for the hook which works in the location you want to add the content.

Hook Manager - Post Hooks

When you arrive at the Post Hooks, you’ll see a range of different boxes which represent the different locations of hooks for that particular section.

Here’s the 4 locations of the hooks for the Post section:

woo_post_before – Executed before each post.

woo_post_inside_before – Executed at the top, inside each post’s DIV tag.

woo_post_inside_after – Executed at the bottom, inside each post’s DIV tag.

woo_post_after – Executed after each post.

Hook Manager - Post Hook Locations

I’m sure by now you understand what hooks are so all you need to do is add the text or code to the correct box and the content will display in that location on all posts.

Not many themes offer a hook manager like Woo Themes so if you’re not using this theme you’ll need to add the hook and function along with other code and text to your themes functions.php file

Here’s a complete map of all Woo Hooks and the locations they execute.

Woo Themes Hook Map

woo-theme-canvas-hooks

You can use this map along with the Hook Manager to add text, html, links or even ads to any location which offers a hook by simply pasting the code into the correct box inside the Hook Manager.

This is a great way to start learning about hooks if you plan on learning php code where hooks and filters play a large part in WordPress customization.

Another great feature of the Hook Manager is you can  execute WordPress shortcodes in they hook locations as well.

Using Woo Hooks In Custom Functions

If you want to add content to any of the hooks positions in a Woo theme, you can also use a custom function. The custom functions should be placed in your child themes functions.php file.

As you can see with the Hook Manager, it doesn’t enable you to use every hook that Woo offers so you may need to use a custom function instead.

Here’s a few examples of PHP code using some popular hooks which are included in all Woo themes.You can use or modify these code snippets in order to hook in content or filter a function using any of the Woo hooks available.

All Woo Hooks

You can use all of these hooks in custom functions in your child themes functions.php file or the custom PHP section of your themes functions file:

* - woo_head()
 * - woo_top()
 * - woo_header_before()
 * - woo_header_inside()
 * - woo_header_after()
 * - woo_nav_before()
 * - woo_nav_inside()
 * - woo_nav_after()
 * - woo_content_before()
 * - woo_cotnent_after()
 * - woo_main_before()
 * - woo_main_after()
 * - woo_post_before()
 * - woo_post_after()
 * - woo_post_inside_before()
 * - woo_post_inside_after()
 * - woo_loop_before()
 * - woo_loop_after()
 * - woo_tumblog_content_before()
 * - woo_tumblog_content_after()
 * - woo_sidebar_before()
 * - woo_sidebar_inside_before()
 * - woo_sidebar_inside_after()
 * - woo_sidebar_after()
 * - woo_footer_top()
 * - woo_footer_before()
 * - woo_footer_inside()
 * - woo_footer_after()
 * - woo_foot()

On top of this, Woo also offer a huge range of hooks for the Woo Commerce plugin.

Add Widget To Any Woo Theme

Here’s an example of using using a hook to create a widget:

/** Register Before Post Widget Area.*/
function wpsites_before_post_widget() {

	 register_sidebar( array(
		'name' => 'Before Post Widget',
		'id' => 'before-post',
		'before_widget' => '<div>',
		'after_widget' => '</div>',
	) );
}
add_action( 'widgets_init', 'wpsites_before_post_widget' );

/** Hook In Widget Before Post Content .*/
function before_post_widget() {

if ( is_single() && is_active_sidebar( 'before-post' ) ) { 
            dynamic_sidebar('before-post', array(
	    'before' => '<div class="before-post">',
            'after' => '</div>',
	) );

      
    }
        
}

add_action( 'woo_post_before', 'before_post_widget' );

The above code will create a new widget which displays your content before all single posts.

Please copy ALL the PHP code above and paste it in the custom functions section of your themes functions.php file or in the functions file of your child theme.

Other Themes Hook Options

Clearly Woo themes hook manager is lacking when compared to some of the most popular theme frameworks which also provide a feature like this.

The Genesis Simple Hooks plugin and Thesis hook management plugin are far superior as they enable you to execute PHP code in any hook position which isn’t possible with Woo’s hook manager.


Comments

32 responses to “Easy Way To Add Content Using Woo Themes Hook Manager”

  1. Hi Brad,

    this is the best tutorial about Woothemes hooks I was able to find on the web! Thank you!

    I’ copy-pasted your “Add Widget To Any Woo Theme” code on mywebsite (that runs “Definition” Woothemes) and I can see the widget on the backend.

    However if I insert anyething on the widget (a text, a category list or whatever) it doesn’t show up. I don’t think it’s a cookie issue cause any other modification (such as adding a widget on the sidebar) shows up.

    Any thoughts on why the code doesn’t show up? Are these hooks only valid for Canvas or for all Woothemes?

    Thank you!

    1. Brad Dalton Avatar
      Brad Dalton

      I tested the code again and it works perfectly.

      It only displays on single posts because it includes a conditional tag is_single() which you can change or remove.

      Where did you paste the code?

      It needs to be pasted in your functions file.

      Did you copy every single character of the code?

      1. Hey Brad,

        thank you for answering so fast! Yup, I copy pasted to Functions.php all your code from

        “/** Register Before Post Widget Area.*/”
        to
        “add_action( ‘woo_post_before’, ‘before_post_widget’ );”

        Also,

        1) We are testing this on a mirror without Child theme or customization (I thought maybe this was an issue)

        2) I’ve deactivated ALL the plugins to make sure there were no conflicts

        3) I believe that when you say “It only displays on single posts” you mean that only displays on /blog/hello-world/ (just an example) and not on /blog/. But I can’t see it even on single posts.

        But I still cant see the code.

        We use “Definition” Woothemes, not “Canvas”. Maybe this is the problem?

        1. Brad Dalton Avatar
          Brad Dalton

          The code in this post is tested and works perfectly.

          No offense but considering you haven’t even been able to paste the code in the comments correctly indicates to me you haven’t been able to paste it correctly in your theme files.

          The code you pasted is NOT part of the code included in this posts which is probably why it doesn’t work.

          You may have also copied and.or pasted it incorrectly and/or pasted it it in the wrong position in the file.

          Please read this post Ivo http://wpsites.net/wordpress-tips/reasons-code-doesnt-work-how-to-fix-it/

          1. No offense taken Brad, you’re the only one on the web that seems to talk about this issue!

            And my intention is not to piss you off claiming that your code doesn’t work, I just would like to make it work on my sites too : )

            And it works on the backend (I can use the widget called “Before Post widget”) but nothing shows up.

            I’ve checked again the code on this article. And, indeed, this is the last row I see (after the same code you pasted on the comments):

            add_action( ‘woo_post_before’, ‘before_post_widget’ );

            I got a screenshot if you want because it seems you don’t see it now…

            I tried the code on the your last comment (same code without the last line) and I get the same result: it works on the backend but nothing shows up.

            I’ve checked your article about mistakes and I’m not doing any of them. I’ve submitted the site on browsershots dot org and still nothing.

          2. Brad Dalton Avatar
            Brad Dalton

            Its all good Ivo.

            I think you’ll learn a lot from this as i deal with dozens of local errors like this everyday while writing code and its a great way to learn.

            If you can paste the code in Github Gist and link to it from a comment i will copy and paste it into a Woo theme and test it.

          3. The funny stuff is that if I change hook, for instance putting:

            add_action( ‘woo_header_before’, ‘before_post_widget’);

            instead of

            add_action( ‘woo_post_before’, ‘before_post_widget’);

            The code works perfectly, that is I can see the changes on the header hook. So it’s obviously not your code that is wrong not me doing something wrong.

            Is a problem with Woothemes ” post” hooks.

          4. Brad Dalton Avatar
            Brad Dalton

            Maybe you have another function using the same hook.

            Hard to say accurately what the problem is without looking at all the code and plugins you have installed.

            I deal with issues like this every day and eventually you will resolve and learn from it.

          5. Hi there,

            I’ve solved the issue and I wanted to share the solution so that future readers won’t have my same problem.

            1) After contacting Woothemes support they confirmed my theory: not all Woothemes have all the hooks by default.

            2) If after copy-pasting the code provided on this article to Function.php (use the one on the article, the one posted by Brad on this comment thread is missing the last function call so it won’t work) you can’t see nothing, you shall add the following code:

            (use the hook you need!)

            to Single.php (for displaying on single post; be careful, the position matter!) and/or to Content.php (for displaying on archives, blog thread etc).

            3) At this point it shall show up on any Wootheme.

            Thank you again Brad, awesome article!

            Cheers,

            I.

          6. Brad Dalton Avatar
            Brad Dalton

            Hey Ivo

            That’s really funny and thanks for sharing your solution.

            Not all Woothemes have all the hooks by default.

            That explains it.

            But the code i posted does work perfectly on the Canvas theme by Woo, they just don’t make it known that not all their themes include their hooks.

          7. ok, the code didnt: show up, here it is: https://gist.github.com/anonymous/09ccf4faac53eb319ccb

          8. Brad Dalton Avatar
            Brad Dalton

            So you will need to copy over your single.php file to your child theme and add this hook in the position you want to output your widget.

            [code]

            [/code]

            Another option is to call the widget directly from your single.php file using code like this:

            You’ll also need to use the first snippet of code which registers your widget in your functions file.

  2. Jacob Avatar

    Hey Brad, Nice tutorial you’ve got here.

    I’ve tried adding adsense to the bottom of the post using the hook manager, the only problem with that is that the ads will show up on every post on the home page. Is there anyway of having them just on the post page and not the homepage?

    I’ve tried adding the code in the content-post.php and single.php with no luck.

    1. Brad Dalton Avatar
      Brad Dalton

      Hi Jacob

      Find the sub heading for adding content after all single posts and add that PHP in your themes functions.php file.

      1. Jacob Avatar

        Hey Brad thanks for the advice.

        Another way I was told how to do it which is working:

        Install WP Conditional Shortcodes plugin
        Inserted the shortcode and adsense code into the hook manager
        [is_single]
        your adsense code_here
        [/is_single]

        Jacob

        1. Brad Dalton Avatar
          Brad Dalton

          Good tip. Thanks for sharing Jacob.

        2. Yes, thanks Jacob. That would perfectly for me.

  3. This article misses the point – where do you manage hooks. I’ve done it once and can’t remember how to get back to them

    1. Brad Dalton Avatar
      Brad Dalton

      Depends on which theme you are using but Woo Hooks provide a hook manager so you simply enter in your content to display it in that location.

      Thesis and Genesis also offer hook plugins or you can add the hook to a custom function.

      If your theme doesn’t offer hooks, you can add custom hooks to your parent themes template files easily enough.

      How does this article miss the point? And what point are you referring to?

  4. Coach Comeback Avatar
    Coach Comeback

    OH… and don’t even get me started on Thesis!!!!!!!!!!

    That is a newbies NIGHTMARE!!!! X-O

    1. Great support on the Thesis forums but its mostly for designers as they don’t make child themes like SP.

      1. No worries Colin. There’s a heap of code on Github and Pastebin as well.

  5. Coach Comeback Avatar
    Coach Comeback

    Also cant get the hook section to work with another plugin’s shortcodes. I want to put optin box after my post but when I put the shortcode of the plugin in the hook section is does not show. If I put any other html codes it works fine.

    Is there a way to make it work with other plugins shortcodes?

      1. P. James Holland Avatar
        P. James Holland

        James Holland lol Most curious reply indeed? I tried a different option and got it to work. So I am happy now. Still learning Woo Themes framework

        1. Good stuff James! I use the Genesis theme framework and SP child themes. Woo have been very disappointing.

          1. Coach Comeback Avatar
            Coach Comeback

            I agree Brad. I switched from Woothemes to Genesis last summer and was loving it… That is, until I needed to change out my header and could not do it without playing with code.

            I am soooo non-techy that I have to choose what works with the least amount of mouse clicks. I definitely prefer Genesis…. but woothemes tend to work more out-of-the-box for me and the admin panel is very dummy proof.

            Simplicity wins.

          2. Come over to the StudioPress Community forums where i volunteer if you need help. I’ll look after any coding stuff you need.

  6. I am trying to use the hook feature, do you know if its normal for everything to disapear after you save it? Does it uspport Javascript? I am trying to ad adsense code and it doesn’t appear to be working.

    1. Hello Cecily. I don’t think it does. Only shortcodes and HTML. Try posting this question in the Woo forums as they should have a solution for you. http://www.woothemes.com/support-access/

      You could create a widget area using hooks and then drag in a Adsense or text widget with your javascript.

      Another option is to use this code on this page in your Woo theme template files or add it to a custom function using Woo hooks.

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.