-
Notifications
You must be signed in to change notification settings - Fork 1
/
archive-product.php
79 lines (55 loc) · 1.35 KB
/
archive-product.php
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
<?php
/**
*
* @package wpland
*/
get_header();
?>
<div class="container">
<div class="section_title">
<h2> ALL Products</h2>
</div>
<div class="product-grid">
<?php
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'product',
'posts_per_page' => 4,
'paged' => $paged);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();?>
<div class="product-card">
<div class="product-header">
<?php wpland_post_thumbnail('full'); ?>
</div>
<div class="product-body">
<h3 class="product-title"><?php the_title();?></h3>
</div>
<div class="product-footer">
<a href="<?php echo esc_url( get_permalink() ) ?>" class="button">Read More</a>
</div>
</div>
<?php endwhile; ?>
</div>
<div class="container">
<nav class="pagination">
<?php
$total_pages = $loop->max_num_pages;
if ($total_pages > 1){
$current_page = max(1, get_query_var('paged'));
echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'format' => '/page/%#%',
'current' => $current_page,
'total' => $total_pages,
'prev_text' => __('« Back'),
'next_text' => __('Next »'),
));
}
wp_reset_postdata();
?>
</nav>
</div>
</div>
<?php
get_footer();