YaySwatches Documentation
  • YaySwatches Documentation
  • Getting Started
    • Introduction
    • How to Install
    • Enter license key
    • System Requirements
    • How To Update YaySwatches
    • Uninstall and Delete
  • How It Works
    • How to Create Product Attributes
    • How to Add Attribute to Products
    • Variant Option Settings
    • Swatch Customizer
    • Button Customizer
    • Sold Out Customizer
    • Shop or Categories Customizer
    • Add Swatch When Editing Product
    • Hooks and Shortcodes
  • Integrations
  • Why Upgrade?
  • Other Links
    • FAQs
    • Changelog
    • Useful Links
    • Support
Powered by GitBook
On this page

Was this helpful?

  1. How It Works

Hooks and Shortcodes

PreviousAdd Swatch When Editing ProductNextIntegrations

Last updated 1 year ago

Was this helpful?

  1. Hooks

  • Filter yay_swatches_show_all_pages hook is used to display YaySwatches on a page.

Currently in YaySwatches settings, attributes are displayed only on Single Product Page and Shop/Categories Page. To display YaySwatches on other pages, you can add the following code to or to the file functions.php of your theme.

add_filter( 'yay_swatches_show_all_pages', '__return_true' );
  • Filter hook to show/hide term name on variant: yay_swatches_show_term_name_variant_button, yay_swatches_show_term_name_variant_custom, yay_swatches_show_term_name_variant_image

add_filter( 'yay_swatches_show_term_name_variant_button', '__return_true' );
add_filter( 'yay_swatches_show_term_name_variant_custom', '__return_true' );
add_filter( 'yay_swatches_show_term_name_variant_image', '__return_true' );
  1. Shortcodes

  • [yay-swatches-variant-html]: You can use this shortcode to display YaySwatches by product ID

Eg: Display attribute of product ID 21

  • [yay-swatches-variant-loop] shortcode is to show YaySwatches in Products Loop.

These provided hooks and shortcodes are fully functional only in the YaySwatches pro version.

Code Snippets
Add YaySwatches shortcode to display attribute
Attribute displayed in the front end