• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2784

Original Genesis Tutorials & 6000+ Guaranteed Code

Snippets

  • Consultation
  • Full Access
  • Log in

Using Hooks In Woo Themes

Unlike the Genesis and Thesis hook plugins, the Woo Hook Manager in the Canvas theme doesn’t enable you to execute PHP or Javascript code.

So whats the solution?

You’ll need to add the code in your themes templates files or better still, write a custom function which you can also use with conditional tags.

Lets take a look at some examples of code you can add to your child themes functions.php file to display banners, ads or pretty much anything else in different hook locations your Woo theme offers.

Display In WordPress Footer Based On Conditions

This code will work in any theme because it uses a WordPress hook and not a theme specific hook.

Change the conditional tag to whatever you like.

In the above example i’ve used a conditional tag for pages and added the page i.d of 100 which you will change to your own.

Execute Code In Any Theme Head Section

If you simply want to display content using the wp_head hook in WordPress, you can add this code to your child themes functions.php file.

This code will work with any theme.

You can change the WordPress hook wp_head to any other hook including theme specific hooks.

Note: Using the wp_head hook to load Javascript requires the files to be enqueued before the wp_head action hook.

Woo Specific Hooks

This code will output your content after the posts content in a Woo theme only.

You can easily change the Woo ‘woo_post_after’ hook to another.

The below example will output your HTML before the posts content.

But Wait! There’s a Problem.

The code will also output on archives pages like you blog or homepage. So how do we fix that?

We add a conditional tag so it only displays on single posts and/or single pages. Not on archive pages.

Add Content After All Single Posts

This code displays after all posts on single posts only.

Add Content Before All Single Posts

This code displays before all page content on pages only including archive pages.

These are some examples which you can use in a Woo theme. The code snippets using the WordPress wp_head or wp_footer action hooks can be used in any theme.

Hook Reference Map

Here’s a complete list of Woo hooks displayed in a visual map.

Reader Interactions

Comments

  1. Scott says

    June 24, 2014 at 5:42 pm

    Hi Brad,

    Is there a way to modify this so that it shows after the first post only?
    Thanks,

    Scott

    add_action('woo_post_after', 'wpsites_display_content_post_after');
    function wpsites_display_content_post_after() {
    echo 'Display Content Site Wide Post After Hook';
    };
    Log in to Reply
    • Brad Dalton says

      June 25, 2014 at 3:07 am

      Shows after the 1st post on archive pages or home page or?

      Log in to Reply
      • Scott says

        June 25, 2014 at 10:48 am

        Hi Brad,

        What I am trying to do is add content after the first and second posts on the archive pages.

        Sorry for the confusion,

        Scott

        Log in to Reply
        • Brad Dalton says

          June 25, 2014 at 1:15 pm

          No worries. Try this http://wpsites.net/web-design/add-content-after-any-number-of-post-excerpts-in-any-type-of-archive/

          Log in to Reply
  2. Cecily says

    May 30, 2014 at 5:53 pm

    Hi Brad, being that Canvas doesnt allow us to execute PHP or Javascript code, how would I relocate the post titles and meta data above the Featured Image? I think its strange that these items are reversed and most of my clients want their posts to display this way. Any hints would be appreciated!

    Log in to Reply
    • Brad Dalton says

      May 30, 2014 at 6:06 pm

      I think the best solution would be to use something like what you can use with Genesis like a remove_action and then add_action.

      You just need to find the correct hook and function names which isn’t that easy in Canvas as there’s over 100 files.

      Another solution is to copy over the files to your child theme and edit theme there but that’s really not the best method.

      I would ask this question on the Woo Community forums and see if you get answer but i don’t know the exact action names and would need to look in the files to find them.

      Log in to Reply
  3. Judah says

    February 1, 2014 at 8:15 pm

    Hi, Is there a code snippet that will display the hooked content (like a slider) on only the front page? Thanks

    Log in to Reply
    • Brad Dalton says

      February 2, 2014 at 7:23 am

      Add the

      is_front_page()

      conditional tag after the function.

      function slider_front_page() {
      if (is_front_page() && function_exists( 'soliloquy_slider' ) ) {
      soliloquy_slider( '88' );
         }
      }
      add_action('woo_header_inside', 'slider_front_page');
      Log in to Reply
  4. Bradley Charbonneau says

    February 2, 2013 at 10:57 pm

    Brad, you’re a rockstar!

    Dear WP Sites readers, I asked a quickie question in a comment the other day to Brad and not only did he answer it, he wrote up a whole post pummeling the question with several solutions. That is going above and beyond.

    Big brownie points in my book, Brad. How can I return the favor? IMHO, the WordPress world is one of cooperation and it’s been working great for me for years. Let me know if you need anything.

    Best regards,

    Bradley

    Log in to Reply
    • Brad Dalton says

      February 3, 2013 at 1:18 am

      hahaha! Its because you’ve got a cool name Bradley! I really do appreciate it when my readers leave comments and tell me what they need because it gives me ideas on what to write about. Keep them coming because i need to offer a diverse range of solutions and don’t want to focus on one specific theme. Cheers

      Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags