Title: Inserting things into category list
Last modified: June 6, 2020

---

# Inserting things into category list

 *  Resolved [o0MSK0o](https://wordpress.org/support/users/o0msk0o/)
 * (@o0msk0o)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/inserting-things-into-category-list/)
 * I’m not sure if this is the right place to ask for these sorts of questions, 
   but I was wondering if anyone had any suggestions for a clean way to add things
   within the category list in the archive page.
 * My design looks like this: [https://imgur.com/a/fb6NrMZ](https://imgur.com/a/fb6NrMZ)
 * It has a section within the category list advertising a sale. But I cannot think
   of a clean way to add that–displaying that isn’t a problem but displaying it *
   in the right place* is.
 * The category list is displayed through the `woocommerce_maybe_show_product_subcategories`
   function (hooked into the `woocommerce_product_loop_start` filter) which calls`
   woocommerce_output_product_categories` to actually output the list.
 * Since the loop for displaying categories is inside a function (as opposed to 
   within a template) I’m not sure how I’d go about modifying it.
 * All I can think of is duplicating both functions and changing my `maybe_show_product_subcategories`
   function to use the duplicated `output_product_categories` function, then removing
   the original filter and adding my updated one.
 * That feels very messy though, and like it might break something in a future update.
   Any suggestions for a clean way to change it?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/inserting-things-into-category-list/#post-12951366)
 * I would think any change to your list of categories would break such a setup 
   however it was coded.
 * You could make your own custom shop page using shortcodes interspersed with your
   the other content.
    [https://docs.woocommerce.com/document/woocommerce-shortcodes/](https://docs.woocommerce.com/document/woocommerce-shortcodes/)
 * Use a redirect plugin to push shop links to your custom shop page.
 *  Thread Starter [o0MSK0o](https://wordpress.org/support/users/o0msk0o/)
 * (@o0msk0o)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/inserting-things-into-category-list/#post-12965392)
 * Hi [@lorro](https://wordpress.org/support/users/lorro/),
 * Thanks for the response.
 * > I would think any change to your list of categories would break such a setup
   > however it was coded.
 * What do you mean? Do you mean in terms of breaking the layout? That shouldn’t
   be a problem–I just need to make sure it’s only output every three items. If 
   I can edit the PHP within the loop that won’t be a problem–I just need to add
   a variable containing the current category count and check `($i%3===0)`. E.g.
 *     ```
               foreach ( $product_categories as $i=>$category ) {
                   wc_get_template(
                       'content-product_cat.php',
                       array(
                           'category' => $category,
                       )
                   );
                   if($i%3===0) {
                       // output sales ad
                   }
               }
       ```
   
 * It’s just that I didn’t want to have to recreate the `woocommerce_output_product_categories`
   function. I want this to be in the theme, so I think that’s the route I’ll have
   to take–though it does feel very messy.
 * Thanks for trying to help.
    -  This reply was modified 5 years, 11 months ago by [o0MSK0o](https://wordpress.org/support/users/o0msk0o/).
    -  This reply was modified 5 years, 11 months ago by [o0MSK0o](https://wordpress.org/support/users/o0msk0o/).
 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/inserting-things-into-category-list/#post-12967456)
 * That looks like a good fix and shouldn’t break the layout.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Inserting things into category list’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [category loop](https://wordpress.org/support/topic-tag/category-loop/)
 * [product archive](https://wordpress.org/support/topic-tag/product-archive/)

 * 3 replies
 * 2 participants
 * Last reply from: [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * Last activity: [5 years, 11 months ago](https://wordpress.org/support/topic/inserting-things-into-category-list/#post-12967456)
 * Status: resolved