I want to add a space for a banner across the top of my WooCommerce Category pages, but i'm trying to figure out how to add some markup that will wrap the action.

In my archive-product.php I have the following code;


Basically, if a Category has the 'category_promo_header' Action Hook Name set, I would like to output the content and wrapped in some additional markup such as;

<div class="row">...</div>

I want to do it this way so that the client doesn't have to remember to add the additional makeup every time. Do I need to do this in the functions.php or can i place some conditional in the archive-product.php?


1 Answer 1


You want the has_action() function.

  function () {
    echo 'hi there';

if (has_action('category_promo_header')) {
  echo '<div>';
  echo '</div>';

Comment that add_action and you should see that nothing is printed at all.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.