I'm new to WordPress and trying out woocommerce, but I've ran into a small problem.

Here is my site.

The products pages are no childs of the Shop page, so whenever I click on a product, the active underline under Shop disappears. Does anyone know how to change this? Im using the Mystile theme.

  • There's WooCommerce specific permalinks options, does that make any difference? – Ewout Apr 26 '13 at 20:35
  • Ahh thanks. I was able to change the permalinks, so the collections and product was child of the shop, but sadly the "active" styling of the a tag, doesn't work when im in the category or in a product. Any idea how to do that? :) – McKeene Apr 26 '13 at 21:30

You don't need to force the permalink structure to do this. These effects are usually handled by adding some class (with a specific style) to the item you want to highlight, in this case the <li> containing the link to the shop.

In your site, the Shop menu entry (when in the Shop page) is:

    <li id="menu-item-23" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item current_page_item menu-item-23">
<a href="http://md4s1307.keaweb.dk/shop/">Shop</a>

Both li.current-menu-item > a and li.current_page_item > a are styled in your theme with the special color. You just need to add either of these classes to the li element in the single product pages, which you can do with:

jQuery(document).ready(function(e) {e('#menu-item-23').addClass("current-menu-item");...}

For a quick fix, you could simply modify your script single-product.js (which presumably loads just for single product pages) to include this snippet within its "document ready". Obviously all warnings about modifying code that you later may want to update (i.e. your theme) apply, but that's for a different question.

You could also attempt to be more general and locate the menu item whose text content is "Shop", etc.

| improve this answer | |
  • Thanks a lot for your help :) I also found another way of doing it. I changed the permalinks and then the menu item would get a .current_page_parent when in a category or product, which i could style with the color. – McKeene Apr 30 '13 at 16:02
  • @McKeene, this is a perfect example of a situation where you should have posted your own answer, rather than just accepting one you didn't use. I too have this problem and I'm interested in exactly how you fixed it with the permalink settings. – Sparky Aug 6 '14 at 23:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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