Hooks and Shortcodes

  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 Code Snippets 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.

Last updated