Ad
Woocommerce How To Add Title Attribute To Anchor Tag For Product Name On Mini Cart
I want to add a title attribute to the anchor tag for the product names in the Woocommerce mini cart, so that when a customer hovers over the product name, a toolbox will appear with the product name.
<a href="" title=""></a>
Is there a function to achieve this?
Ad
Answer
Copy the file found at
wp-content/plugins/woocommerce/templates/cart/mini-cart.php -> wp-content/themes/your-theme/woocommerce/cart/mini-cart.php
into your store’s child theme .
Note that if you customize the parent theme rather than the child theme, any changes will be overwritten with theme updates.
Change code in wp-content/themes/your-theme/woocommerce/cart/mini-cart.php
Before
<a href="<?php echo esc_url( $product_permalink ); ?>">
<?php echo $thumbnail . wp_kses_post( $product_name ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</a>
After
<a href="<?php echo esc_url( $product_permalink ); ?>" title="<?php echo esc_attr($product_name); ?>">
<?php echo $thumbnail . wp_kses_post( $product_name ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</a>
Fоr tooltip you can use 'jquery-ui'. Add below code to functions.php of your theme
function my_scripts_method() {
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-core');
}
add_action('wp_enqueue_scripts', 'my_scripts_method');
You need to add this code to your theme in js file
jQuery( function() {
jQuery( '.woocommerce-mini-cart-item a').tooltip();
} );
Ad
source: stackoverflow.com
Related Questions
- → CORS missmatch because of http
- → Building sitemap for 2 wordpress install under 1 domain
- → How to remove empty elements after class?(jQuery)
- → Get width of an element and apply to another relative to the first one?
- → How to remove caption p class from wordpress?
- → 301 Redirection from no-www to www in wordpress
- → Laravel 5 routing using prefix
- → WordPress - Header position Top, Left &Right
- → how to add rel=nofollow to some specific external links in wordpress
- → octobercms install error: database is not empty?
- → How to edit the index page of wordpress theme?
- → How to select a Post Type (Wordpress) to pass a filter in head?
- → What sort of URL structure should be used to display AMP HTML vs vanilla HTML
Ad