WooCommerce: modify Layered Nav Widget output - php

I need to modify WooCommerce's Layered Nav Widget output so that it wraps each widget's instance into a <div> tag and add an additional class based on the current attribute slug to each <li> element.
I know how to do that, but I don't want to alter the original widget file.
Is there any way to substitute the original WooCommerce widget file with modified one as I can do with WooCommerce templates?
I suppose I can also put a custom function into functions.php but the level of my experience advises I can't do that myself.

Related

WooCommerce removing wrapping tags from products/categories

Is it possible to remove tags, such as the <li> tags from around the products/categories in WooCommerce? I have tried searching for hooks, and more. Also, I successfully removed the <ul> tags from around the product set as well. I would like to spit out all product data in my cell since I am using foundation framework. Is this possible, or do I have to take an alternative route?
To change the html structure in Woocommerce
You should need, most of the time, to make changes in the available Woocommerce templates.
First you should read how to override woocommerce templates via your active theme
Now to change (or remove) the <li> tags on products and product category archives, you need to override content-product.php and content-product_cat.php templates file.

woocommerce add subtitle on menu navigation on my account

i got in stuck with a customization that i want to do on myaccount navigation menu in the Woocommerce account.
I want to add inside the li tag a subtitle under the menu item name, the item that he get from wc_get_account_menu_items() function, but it doesn't have any subtitle in the $item.
How can i customize it in order to insert it in the navigation.php
I attach a file where it shows how it have to be rendered
I thought to insert an action at wc_get_account_menu_items in order to add teh subtitle but i can't figure out how :(
Thank you
Mirko
You can't get the HTML you required (as per screenshot) using woocommerce_account_menu_items() filter or any other filter.
So if you need the same structure, it is better to hard code the links & HTML in your theme by copying navigation.php from wp-content\plugins\woocommerce\templates\myaccount to wp-content\themes\your-theme\woocommerce\myaccount.

VisualComposer - custom layout for block

In wordpress visual composer I have block with some articles and I want to display them in custom way so I need to add some layout which can be available from layouts list (screen below). What is the correct way to add custom layout for some elements? I don't want to lose my custom layout during vc update.

How to make possible dynamically add 'active' class to current page in wordpress

i want to highlight current menu by adding class active to <li> in wordpress.
the menus are created dynamically in wordpress, is it possible to highlight current menu.
Wordpress does this natively. Assuming you're using wp_nav_menu() to generate the html (you shouldn't use wp_list_pages() for nav menus though a similar answer exists if you are), it will add class="current-menu-item" to the current menu item. It actually adds a whole bunch of useful classes to the menu html outlined here.
Is there a reason that the css class has to be .active? If so, you could consider a jquery method to add the active class based on the native class.

How to add custom html-code to Joomla 2.5 menu items?

Situation: I have old site Agroteplica based on Joomla 2.5. I need to add custom html-code to menu items (for example, icons, or bold). I need unic icon for each menu item, so it's no use to edit php-template of page.
If I try to use html-code in menu item header - Joomla clear it, only text remains. I tried to find some manuals, and added line filter="raw" to file modules.xml:
<field name="title" type="text"
description="COM_MODULES_FIELD_TITLE_DESC"
label="JGLOBAL_TITLE"
maxlength="100"
required="true"
filter="raw"
size="35"
/>
But it didn't give any effect either.
Question: what I need to do to make it work? :)
Here is what Joomla provides for cases like this:
In Menu Manager -> Menu Item Edit
Editing each menu item, you will see the "Link Type Options" section at the right column.
See screenshot:
As you see in the screenshot, this group of settings contains the follow options:
Link Title Attribute : You can add your custom Title attr to the menu item's a tag.
Link CSS Style : You can add a custom css class for this menu item's a tag.
Link Image : You can add a custom image for this menu item.
Add Menu Title : If you add an image, you can choose to hide the Title of the link (setting = No), or choose to show both Image and the title (setting = yes (default)).
For you case, you can either choose you custom images-icons that should be displayed next to your menu items title. If you want bolds or other styling options, you can add your custom css rules to the items you want, and then add your css styles at your template's css.
For example you have decided that for some of your menu-items you would want their text in bold. Then you could do as follow:
1 .Give them a css class to all of them, in the Link CSS Style field: e.g. 'bold-items' (without the '').
2. Open your template's css file with a plain text editor and add the following rule at the end of the document:
.bold-items {
font-weight:bold;
}
Notice: The above settings might have no effect at all, if you are using a 3rd party menu module, or your template contains overrides for the default menu module. In such case you will need to add further template overrides for the menu module in use, in order to implement the above settings.
*Not sure what you mean with menu item header and how you did try to add html-code to it.
*Update / Answer to your comment:
You never mentioned about video in your question. You asked about adding icons and making text bold. What do you mean with headers and what kind of code and where are you trying to insert it? Are you aware of what is involved in the process from the moment you create menu items in the menu manager till you see those in the front-end of your website?
Following my answer above and assuming you have basic knowledge of the workflow (menu module, template overrides, css) you will be able to add images/icons or custom styles for each menu item. If you want to have video inside your menu, then you...
... will need a more sophisticated menu module. These are called Mega Menus and allow the user to display various types of content inside their menus, like modules, in various ways. You should either install a such module or create one on your own.

Categories