In Woocommerce, I would like to add a drop down in product short description that shows all products that have the same category(ies). It will be even better if it was possible
Add this to your theme's 'functions.php' which will display all products of your current product's category.
function add_products_short_description() {
$product_cats = wp_get_post_terms( get_the_ID(), 'product_cat' );
if ( $product_cats ) {
$single_cat = array_shift( $product_cats );
$product_args = array( 'post_type' => 'product', 'posts_per_page' => '-1', 'product_cat' => $single_cat->name );
$products = new WP_Query( $product_args );
if ( $products->have_posts() ) : echo '';
while ( $products->have_posts() ) : $products->the_post(); global $product;
echo '- '.get_the_title($products->ID).'
';
endwhile;
echo '
';
endif;
}
}
add_action( 'woocommerce_single_product_summary', 'add_products_short_description', 15 );