Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
Hello world!
, but we’ll replace the visible header
?>
>
>
‘product’,
‘posts_per_page’ => 9,
‘paged’ => $paged,
‘post_status’ => ‘publish’,
);
if($category !== ‘all’) {
$args[‘tax_query’] = array(
array(‘taxonomy’=>’product_cat’,’field’=>’slug’,’terms’=>$category)
);
}
if($search) {
$args[‘s’] = $search;
unset($args[‘tax_query’]); // search overrides category
}
$query = new WP_Query($args);
ob_start();
if($query->have_posts()) :
while($query->have_posts()) : $query->the_post();
global $product;
$id = $product->get_id();
$title = get_the_title();
$price = $product->get_price_html();
$image = get_the_post_thumbnail($id, ‘medium_large’, array(‘loading’=>’lazy’));
$excerpt = wp_trim_words(get_the_excerpt(), 12);
$add_cart = esc_url($product->add_to_cart_url());
?>
No products found.‘;
endif;
$html = ob_get_clean();
// Pagination
$big = 999999999;
$paginate = paginate_links(array(
‘base’ => ‘#%#%’,
‘format’ => ‘?paged=%#%’,
‘current’ => max(1, $paged),
‘total’ => $query->max_num_pages,
‘prev_text’ => ‘‹’,
‘next_text’ => ‘›’,
‘type’ => ‘array’,
));
$pagination = ”;
if($paginate) {
foreach($paginate as $link) {
if(preg_match(‘/page\/(\d+)/’, $link, $m) || preg_match(‘/paged=(\d+)/’, $link, $m))
$pg = $m[1];
else $pg = 1;
$link = str_replace([‘‘], [‘
Discover Living Art
Curated plants that transform your space
‘product_cat’, ‘hide_empty’ => true ) );
if ( ! empty( $categories ) && ! is_wp_error( $categories ) ) {
foreach ( $categories as $cat ) {
printf( ‘‘,
esc_attr( $cat->slug ), esc_html( $cat->name ) );
}
}
?>
Quick View
Leave a Reply