Skip to content

Instantly share code, notes, and snippets.

@wpweb101
Last active January 11, 2019 14:21
Show Gist options
  • Select an option

  • Save wpweb101/e7b1badffc2338ddbe24 to your computer and use it in GitHub Desktop.

Select an option

Save wpweb101/e7b1badffc2338ddbe24 to your computer and use it in GitHub Desktop.
Add Follow button on woocommerce category archive and tag archive pages
<?php
function wpw_fp_woocommerce_archive_follow() {
if ( is_product_taxonomy() ) {
$term = get_queried_object();
$taxonomy_type = isset( $term->taxonomy ) ? $term->taxonomy : '';
$taxonomy_id = isset( $term->term_id ) ? $term->term_id : '';
if( !empty( $taxonomy_type ) && !empty( $taxonomy_id ) ) {
echo do_shortcode( '[wpw_follow_term_me posttype="product" taxonomy="'.$taxonomy_type.'" termid="'.$taxonomy_id.'"]' );
}
}
}
//add follow functionality for woocommerce archives pages
add_action( 'woocommerce_archive_description', 'wpw_fp_woocommerce_archive_follow' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment