HEX
Server: nginx/1.24.0
System: Linux nowruzgan 6.8.0-57-generic #59-Ubuntu SMP PREEMPT_DYNAMIC Sat Mar 15 17:40:59 UTC 2025 x86_64
User: babak (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/school/wp-content/themes/school/archive-product.php
<?php
/**
 * Template for product archives (custom hero: breadcrumb + title outside hooks)
 * Copy to yourchild/woocommerce/archive-product.php
 */

defined('ABSPATH') || exit;

get_header('shop');
?>
</div>
<?php
/**
 * Unhook Woo's default breadcrumb + header so we can print our own.
 * (Must run BEFORE we call the actions below.)
 */
remove_action('woocommerce_before_main_content', 'woocommerce_breadcrumb', 20);
remove_action('woocommerce_shop_loop_header', 'woocommerce_product_taxonomy_archive_header', 10);

/**
 * Build our own breadcrumb HTML (capture output).
 */
ob_start();
woocommerce_breadcrumb([
	'delimiter' => '',
	'wrap_before' => '<nav class="crumbs" aria-label="Breadcrumb"><ol>',
	'wrap_after' => '</ol></nav>',
	'before' => '<li class="crumb">',
	'after' => '</li>',
	'home' => _x('خانه', 'breadcrumb', 'your-textdomain'),
]);
$breadcrumb_html = ob_get_clean();

/**
 * Figure out a proper title:
 * - Category/Tag/Attr archives → term title
 * - Shop page → Woo page title
 */
$title = is_product_taxonomy()
	? single_term_title('', false)
	: woocommerce_page_title(false);

/**
 * Optional: a short description under the title
 * - For tax archives: term description
 * - For the shop page: use the page excerpt (or leave empty)
 */
$subtitle = '';
if (is_product_taxonomy()) {
	$subtitle = term_description();
} else {
	$shop_id = wc_get_page_id('shop');
	$subtitle = $shop_id && !is_wp_error($shop_id) ? get_post_field('post_excerpt', $shop_id) : '';
}
?>
<!-- ===== CUSTOM HERO HEADER (RTL-friendly) ===== -->
<section class="">
	<div class="container">
		<div class="row py-5 text-center">
			<!-- Left/Main Content -->
			<div class="col mx-auto">
				<!-- Hero Header -->
				<div class="text-center">
					<div>
						<h1 class="display-4 fw-bold"><?php echo esc_html($title); ?></h1>
						<?php
						// Get product categories
						?>
						<nav aria-label="breadcrumb">
							<ol class="breadcrumb justify-content-center mt-3 mx-1">
								<li class="breadcrumb-item">
									<a href="<?php echo esc_url(home_url('/')); ?>">مدرسه نوروزگان</a>
								</li>
								<li class="breadcrumb-item active" aria-current="page">
									<?php echo esc_html($title); ?>
								</li>
							</ol>
						</nav>

					</div>
				</div>
			</div>
		</div>
	</div>
</section>
<section>
	<div class="container">
		<?php
		/**
		 * Keep Woo's opening wrappers, schema, etc.
		 * (We removed only the breadcrumb from this hook.)
		 */
		do_action('woocommerce_before_main_content');
		/**
		 * Keep the rest of Woo’s flow (notices, result count, ordering, loop, pagination, sidebar)
		 */
		if (woocommerce_product_loop()) {
			do_action(hook_name: 'woocommerce_before_shop_loop');

			woocommerce_product_loop_start();
			?>
			<section class="container my-5">
				<div class="row">
					<?php
					if (wc_get_loop_prop('total')) {
						while (have_posts()) {
							?>
							<div class="col-md-3 d-flex">
								<?php
								the_post();

								do_action('woocommerce_shop_loop');

								wc_get_template_part('content', 'product');
								?>
							</div>
							<?php
						}
					}

					woocommerce_product_loop_end();
					?>
				</div>
			</section>
			<?php
			do_action('woocommerce_after_shop_loop');

		} else {
			do_action('woocommerce_no_products_found');
		}
		?>
	</div>
</section>
<?php
do_action('woocommerce_after_main_content');
do_action('woocommerce_sidebar');

get_footer('shop');