hook the product category links in, instead of hard coding into the template. #8575

This commit is contained in:
James Koster 2015-10-01 15:28:57 +01:00
parent fe689d3d24
commit 018bcc9d2d
3 changed files with 48 additions and 27 deletions

View File

@ -521,7 +521,7 @@ if ( ! function_exists( 'woocommerce_template_loop_subcategory_title' ) ) {
/**
* Show the subcategory title in the product loop.
*/
function woocommerce_template_loop_subcategory_title( $category ) {
function woocommerce_template_loop_category_title( $category ) {
?>
<h3>
<?php
@ -538,7 +538,7 @@ if ( ! function_exists( 'woocommerce_template_loop_subcategory_title' ) ) {
* Insert the opening anchor tag for products in the loop.
*/
function woocommerce_template_loop_product_link_open() {
echo '<a href="' . the_permalink() . '">';
echo '<a href="' . get_the_permalink() . '">';
}
/**
* Insert the opening anchor tag for products in the loop.
@ -546,6 +546,18 @@ function woocommerce_template_loop_product_link_open() {
function woocommerce_template_loop_product_link_close() {
echo '</a>';
}
/**
* Insert the opening anchor tag for categories in the loop.
*/
function woocommerce_template_loop_category_link_open( $category ) {
echo '<a href="' . get_term_link( $category->slug, 'product_cat' ) . '">';
}
/**
* Insert the opening anchor tag for categories in the loop.
*/
function woocommerce_template_loop_category_link_close() {
echo '</a>';
}
if ( ! function_exists( 'woocommerce_taxonomy_archive_description' ) ) {
/**

View File

@ -95,7 +95,11 @@ add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_produ
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
add_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );
add_action( 'woocommerce_shop_loop_subcategory_title', 'woocommerce_template_loop_subcategory_title', 10 );
add_action( 'woocommerce_before_subcategory', 'woocommerce_template_loop_category_link_open', 10 );
add_action( 'woocommerce_shop_loop_subcategory_title', 'woocommerce_template_loop_category_title', 10 );
add_action( 'woocommerce_after_subcategory', 'woocommerce_template_loop_category_link_close', 10 );
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );

View File

@ -35,32 +35,37 @@ if ( empty( $woocommerce_loop['columns'] ) ) {
$woocommerce_loop['loop'] ++;
?>
<li <?php wc_product_cat_class(); ?>>
<?php do_action( 'woocommerce_before_subcategory', $category ); ?>
<?php
/**
* woocommerce_before_subcategory hook
*
* @hooked woocommerce_template_loop_category_link_open - 10
*/
do_action( 'woocommerce_before_subcategory', $category );
<a href="<?php echo get_term_link( $category->slug, 'product_cat' ); ?>">
/**
* woocommerce_before_subcategory_title hook
*
* @hooked woocommerce_subcategory_thumbnail - 10
*/
do_action( 'woocommerce_before_subcategory_title', $category );
<?php
/**
* woocommerce_before_subcategory_title hook
*
* @hooked woocommerce_subcategory_thumbnail - 10
*/
do_action( 'woocommerce_before_subcategory_title', $category );
/**
* woocommerce_shop_loop_subcategory_title hook
*
* @hooked woocommerce_template_loop_category_title - 10
*/
do_action( 'woocommerce_shop_loop_subcategory_title', $category );
/**
* woocommerce_shop_loop_subcategory_title hook
*
* @hooked woocommerce_template_loop_subcategory_title - 10
*/
do_action( 'woocommerce_shop_loop_subcategory_title', $category );
/**
* woocommerce_after_subcategory_title hook
*/
do_action( 'woocommerce_after_subcategory_title', $category );
/**
* woocommerce_after_subcategory_title hook
*/
do_action( 'woocommerce_after_subcategory_title', $category );
?>
</a>
<?php do_action( 'woocommerce_after_subcategory', $category ); ?>
/**
* woocommerce_after_subcategory hook
*
* @hooked woocommerce_template_loop_category_link_close - 10
*/
do_action( 'woocommerce_after_subcategory', $category ); ?>
</li>