Created
October 17, 2013 07:10
-
-
Save kloon/7020377 to your computer and use it in GitHub Desktop.
List all vendors shortcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_shortcode( 'list_vendors', 'wc_list_vendors_shortcode' ); | |
function wc_list_vendors_shortcode( $atts ) { | |
$vendors = ''; | |
$terms = get_terms( 'shop_vendor' ); | |
foreach ( $terms as $term ) { | |
$term_link = get_term_link( $term, 'shop_vendor' ); | |
if ( is_wp_error( $term_link ) ) | |
continue; | |
$vendors .= '<h2><a href="' . $term_link . '">' . $term->name . '</a></h2>'; | |
} | |
return $vendors; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
after i post this script at the end of my function file it gives this error
Warning: Cannot modify header information - headers already sent by (output started at wp-content/themes/themename/functions.php:260) in /home/themename/public_html/wp-content/plugins/woocommerce/classes/class-wc-session-handler.php on line 63