-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle-growing-guide.php
More file actions
81 lines (68 loc) · 2.68 KB
/
single-growing-guide.php
File metadata and controls
81 lines (68 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/**
* The template for displaying all single posts.
*
* @package storefront
*/
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main growing-guide" role="main">
<article>
<?php
while (have_posts()) :
// echo "<code>the_post</code><br/>";
the_post();
// echo "<code>storefront_single_post_before</code><br/>";
do_action('storefront_single_post_before');
// echo "<code>content</code><br/>";
remove_action('storefront_single_post_bottom', 'storefront_edit_post_link', 5);
remove_action('storefront_single_post', 'storefront_post_content', 30);
remove_action('storefront_single_post_bottom', 'storefront_post_taxonomy', 5);
// get_template_part('content', 'single');
the_title('<h1 class="entry-title">', '</h1>');
get_template_part('parts/growingguide', 'sections', ['show_images' => true]);
// echo "<code>storefront_single_post_after</code><br/>";
do_action('storefront_single_post_after');
endwhile; // End of the loop.
?>
</article>
<?php
$category = function_exists('get_field') ? get_field('product_category') : null;
if ($category && $category instanceof WP_Term) {
$category_id = $category->term_id;
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'meta_key' => 'yearly_sales',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'term_id',
'terms' => $category_id,
),
),
);
$products = new WP_Query($args);
if ($products->have_posts()) {
// echo "<h2>" . $category->name . "</h2>";
if ($products->found_posts > 1) {
echo "<h2>Varieties</h2>";
}
wc_set_loop_prop('columns', 4);
woocommerce_product_loop_start();
while ($products->have_posts()) {
$products->the_post();
wc_get_template_part('content', 'product');
}
woocommerce_product_loop_end();
wp_reset_postdata();
}
}
?>
</main><!-- #main -->
</div><!-- #primary -->
<?php
do_action('storefront_sidebar');
get_footer();