1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* The Template for displaying product archives, including the main shop page which is a post type archive |
4
|
|
|
* |
5
|
|
|
* This template can be overridden by copying it to yourtheme/woocommerce/archive-product.php. |
6
|
|
|
* |
7
|
|
|
* HOWEVER, on occasion WooCommerce will need to update template files and you |
8
|
|
|
* (the theme developer) will need to copy the new files to your theme to |
9
|
|
|
* maintain compatibility. We try to do this as little as possible, but it does |
10
|
|
|
* happen. When this occurs the version of the template file will be bumped and |
11
|
|
|
* the readme will list any important changes. |
12
|
|
|
* |
13
|
|
|
* @see https://docs.woothemes.com/document/template-structure/ |
14
|
|
|
* @author WooThemes |
15
|
|
|
* @package WooCommerce/Templates |
16
|
|
|
* @version 2.0.0 |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
20
|
|
|
exit; // Exit if accessed directly |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
get_header( 'shop' ); ?> |
24
|
|
|
|
25
|
|
|
<?php |
26
|
|
|
/** |
27
|
|
|
* woocommerce_before_main_content hook. |
28
|
|
|
* |
29
|
|
|
* @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content) |
30
|
|
|
* @hooked woocommerce_breadcrumb - 20 |
31
|
|
|
*/ |
32
|
|
|
do_action( 'woocommerce_before_main_content' ); |
33
|
|
|
?> |
34
|
|
|
|
35
|
|
|
<?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?> |
36
|
|
|
|
37
|
|
|
<h1 class="page-title"><?php woocommerce_page_title(); ?></h1> |
38
|
|
|
|
39
|
|
|
<?php endif; ?> |
40
|
|
|
|
41
|
|
|
<?php |
42
|
|
|
/** |
43
|
|
|
* woocommerce_archive_description hook. |
44
|
|
|
* |
45
|
|
|
* @hooked woocommerce_taxonomy_archive_description - 10 |
46
|
|
|
* @hooked woocommerce_product_archive_description - 10 |
47
|
|
|
*/ |
48
|
|
|
do_action( 'woocommerce_archive_description' ); |
49
|
|
|
?> |
50
|
|
|
|
51
|
|
View Code Duplication |
<?php if ( have_posts() ) : ?> |
|
|
|
|
52
|
|
|
|
53
|
|
|
<?php |
54
|
|
|
/** |
55
|
|
|
* woocommerce_before_shop_loop hook. |
56
|
|
|
* |
57
|
|
|
* @hooked woocommerce_result_count - 20 |
58
|
|
|
* @hooked woocommerce_catalog_ordering - 30 |
59
|
|
|
*/ |
60
|
|
|
do_action( 'woocommerce_before_shop_loop' ); |
61
|
|
|
?> |
62
|
|
|
|
63
|
|
|
<?php woocommerce_product_loop_start(); ?> |
64
|
|
|
|
65
|
|
|
<?php woocommerce_product_subcategories(); ?> |
66
|
|
|
|
67
|
|
|
<?php while ( have_posts() ) : the_post(); ?> |
68
|
|
|
|
69
|
|
|
<?php wc_get_template_part( 'content', 'product' ); ?> |
70
|
|
|
|
71
|
|
|
<?php endwhile; // end of the loop. ?> |
72
|
|
|
|
73
|
|
|
<?php woocommerce_product_loop_end(); ?> |
74
|
|
|
|
75
|
|
|
<?php |
76
|
|
|
/** |
77
|
|
|
* woocommerce_after_shop_loop hook. |
78
|
|
|
* |
79
|
|
|
* @hooked woocommerce_pagination - 10 |
80
|
|
|
*/ |
81
|
|
|
do_action( 'woocommerce_after_shop_loop' ); |
82
|
|
|
?> |
83
|
|
|
|
84
|
|
|
<?php elseif ( ! woocommerce_product_subcategories( array( 'before' => woocommerce_product_loop_start( false ), 'after' => woocommerce_product_loop_end( false ) ) ) ) : ?> |
85
|
|
|
|
86
|
|
|
<?php wc_get_template( 'loop/no-products-found.php' ); ?> |
87
|
|
|
|
88
|
|
|
<?php endif; ?> |
89
|
|
|
|
90
|
|
|
<?php |
91
|
|
|
/** |
92
|
|
|
* woocommerce_after_main_content hook. |
93
|
|
|
* |
94
|
|
|
* @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content) |
95
|
|
|
*/ |
96
|
|
|
do_action( 'woocommerce_after_main_content' ); |
97
|
|
|
?> |
98
|
|
|
|
99
|
|
|
<?php |
100
|
|
|
/** |
101
|
|
|
* woocommerce_sidebar hook. |
102
|
|
|
* |
103
|
|
|
* @hooked woocommerce_get_sidebar - 10 |
104
|
|
|
*/ |
105
|
|
|
do_action( 'woocommerce_sidebar' ); |
106
|
|
|
?> |
107
|
|
|
|
108
|
|
|
<?php get_footer( 'shop' ); ?> |
109
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.