Files
mataba/shop/xshop-theme/search.php
T

44 lines
1.7 KiB
PHP

<?php
/**
* Search Results
*
* @package XShop
*/
declare(strict_types=1);
defined('ABSPATH') || exit;
get_header();
$query = get_search_query();
?>
<div class="xshop-container">
<div class="xshop-layout">
<div class="xshop-layout__content">
<header class="xshop-page-header">
<h1 class="xshop-page-header__title">
<?php if ($query !== ''): printf(esc_html__('Search results for: %s', 'xshop'), '<span>' . esc_html($query) . '</span>'); else: esc_html_e('Search', 'xshop'); endif; ?>
</h1>
<div style="margin-block-start:var(--xshop-space-4)">
<?php get_template_part('template-parts/components/search-form', null, ['placeholder'=>esc_html__('Search…','xshop')]); ?>
</div>
<?php if (have_posts()): ?>
<p class="xshop-text-muted" style="margin-block-start:var(--xshop-space-3)"><?php echo esc_html(sprintf(esc_html__('%s results found', 'xshop'), number_format_i18n((int) $GLOBALS['wp_query']->found_posts))); ?></p>
<?php endif; ?>
</header>
<?php if (have_posts()): ?>
<div class="xshop-grid xshop-grid--posts">
<?php while (have_posts()): the_post(); get_template_part('template-parts/components/post-card'); endwhile; ?>
</div>
<?php get_template_part('template-parts/components/pagination'); ?>
<?php else: ?>
<?php get_template_part('template-parts/components/empty-state', null, ['title'=>esc_html__('No results','xshop'),'text'=>esc_html__('Try different keywords or browse categories.','xshop'),'cta_label'=>esc_html__('Go home','xshop'),'cta_url'=>home_url('/')]); ?>
<?php endif; ?>
</div>
<?php get_sidebar(); ?>
</div>
</div>
<?php get_footer(); ?>