-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharchive-book.php
More file actions
97 lines (66 loc) · 1.92 KB
/
archive-book.php
File metadata and controls
97 lines (66 loc) · 1.92 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/**
* The theme's archive file for books.
*
* @since 1.0.0
* @package KidNiche
*/
// Don't load directly
if ( ! defined( 'ABSPATH' ) ) {
die;
}
get_header();
kidniche_page_start();
kidniche_page_title( __( 'Books', 'KidNiche' ) );
global $wp_query, $post;
if ( have_posts() ) :
?>
<div class="page-content columns small-12 medium-9">
<p>Browse the books created by Susan Case Bonner.</p>
<div class="product-loop">
<ul class="products row <?php echo $wp_query->post_count === 1 ? 'collapse' : ''; ?>">
<?php
// Filter output
add_filter( 'woocommerce_loop_add_to_cart_link', 'kniche_woocommerce_add_to_cart_link_book' );
add_filter( 'woocommerce_get_price_html', '__return_false' );
add_filter( 'post_type_link', 'kniche_book_archive_title_link' );
while ( have_posts() ) {
the_post();
$linked_post = get_post_meta( get_the_ID(), '_product_link', true );
if ( empty( $linked_post ) ) {
continue;
}
$linked_post = get_post( $linked_post );
$post = $linked_post;
setup_postdata( $post );
$max_columns = 1;
include __DIR__ . '/partials/product-loop-single.php';
}
// Reset settings from loop
wp_reset_postdata();
remove_filter( 'woocommerce_loop_add_to_cart_link', 'kniche_woocommerce_add_to_cart_link_book' );
remove_filter( 'woocommerce_price_html', '__return_false' );
remove_filter( 'post_type_link', 'kniche_book_archive_title_link' );
?>
</ul>
</div>
</div>
<?php
endif;
get_sidebar();
kidniche_page_end();
get_footer();
function kniche_woocommerce_add_to_cart_link_book() {
global $wp_query;
return '<a href="' . get_permalink( $wp_query->post->ID ) . '" class="button tiny">Read More</a>';
}
function kniche_book_archive_title_link( $link ) {
global $wp_query;
static $doing;
if ( ! $doing ) {
$doing = true;
$link = get_permalink( $wp_query->post->ID );
$doing = false;
}
return $link;
}