Reequestrian/wp-content/themes/twentytwentyfive-child/page-template/home.php
2025-04-24 10:40:22 +05:30

964 lines
19 KiB
PHP

<?php
/*
Template Name: Home page
*/
get_header();
?>
<?php $banner = get_field('banner_image'); ?>
<style>
.hero-section {
background:
linear-gradient(to left,rgba(117, 117, 117, 0) 0%,rgb(46, 42, 42) ),
url('<?php echo esc_url($banner); ?>') no-repeat center center/cover;
color: #fff;
height: 100vh;
position: relative;
display: flex;
flex-direction: column;
}
.hero-header {
background-color: #ffffff;
padding: 15px 50px;
display: flex;
align-items: center;
justify-content: space-between;
font-family: 'Poppins', sans-serif;
position: relative;
z-index: 2;
}
.hero-container {
display: flex;
align-items: center;
width: 100%;
max-width: 1200px;
margin: 0 auto;
}
.logo img {
height: 40px;
}
.hero-nav {
flex-grow: 1;
display: flex;
justify-content: start;
}
.nav-menu {
display: flex;
list-style: none;
gap: 40px;
margin: 0;
padding: 0;
}
.nav-menu li {
position: relative;
}
.nav-menu > li > a {
text-decoration: none;
color: #000;
font-weight: 400;
font-size: 16px;
font-family: 'Poppins';
}
.has-dropdown:hover .dropdown {
display: block;
}
.dropdown {
position: absolute;
top: 100%;
left: 0;
background-color: white;
padding: 10px 0;
list-style: none;
display: none;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
z-index: 10;
}
.dropdown li a {
display: block;
padding: 10px 20px;
color: #000;
text-decoration: none;
white-space: nowrap;
font-weight: 400;
font-size: 16px;
font-family: 'Poppins';
}
.dropdown li a:hover {
background-color: #f0f0f0;
}
.search-container {
position: relative;
width: 100%;
max-width: 360px;
}
.search-input {
width: 100%;
padding: 10px 16px 10px 16px; /* padding-right for icon space */
border: 1px solid #ccc;
border-radius: 1px;
font-size: 16px;
font-family: 'Poppins', sans-serif;
box-sizing: border-box;
}
.search-container img {
position: absolute;
right: 12px;
top: 50%;
transform: translateY(-50%);
width: 25px;
height: 25px;
pointer-events: none;
opacity: 0.6;
}
.hero-content {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
/* padding: 0 100px; */
margin-left:315px;
max-width: 800px;
z-index: 1;
}
.hero-content h1 {
font-family:'Cormorant';
font-size: 88px;
font-weight: 600;
margin-bottom: 20px;
color: #fff;
}
.hero-content p {
font-family:'Poppins';
font-weight: 400;
font-size: 18px;
line-height: 1.6;
margin-bottom: 30px;
color: #eee;
}
.hero-button {
background-color: #004225;
color: #fff;
padding: 12px 24px;
text-decoration: none;
border-radius: 5px;
font-weight: 400;
display: inline-block;
width: 136px;
font-size: 16px;
}
.hero-button:hover{
color: #ffffff;
text-decoration: none;
}
.home-section {
font-family: 'Poppins', sans-serif;
padding: 40px 20px;
background: #fff;
color: #1a1819;
}
/* Subheading and heading */
.subheading {
color: #B08722;
font-size: 14px;
letter-spacing: 1px;
font-weight: 500;
text-transform: uppercase;
text-align: center;
}
.heading {
font-family:'Cormorant';
font-weight:500;
font-size: 44px;
text-align: center;
margin: 10px 0 30px;
}
/* Categories Grid */
.categories-grid {
display: flex;
justify-content: center;
flex-wrap: wrap;
gap: 28px;
}
.category-item {
max-width: 309px;
text-align: center;
}
.category-item img {
width: 100%;
margin-bottom: 10px;
}
.category-item p {
font-style:'Poppins';
font-size: 18px;
font-weight: 400;
}
/* Rider Sale Banner */
.rider-sale-banner {
display: flex;
position: relative;
margin: 60px auto;
max-width: 1320px;
overflow: hidden;
}
.rider-banner {
display: flex;
position: relative;
margin: 60px auto;
max-width: 1320px;
overflow: hidden;
flex-direction: column;
}
.apparel{
background: #EFEBE44D 30%;
}
.rider-sale-banner img {
/* width: 100%; */
height: auto;
display: block;
}
.sale-content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: #fff;
padding: 20px;
text-align: center;
max-width: 410px;
}
.sale-content .discount {
font-size: 18px;
color: #1A1819;
font-weight: 500;
margin-bottom: 8px;
letter-spacing: 1px;
}
.sale-content h3 {
font-size: 32px;
font-family:'Cormorant';
font-weight:600;
line-height:44px;
margin-bottom: 10px;
}
.sale-content p {
font-size: 14px;
margin-bottom: 20px;
color: #1A1819;
}
.btn {
background: transparent;
border: 1px solid #143D28;
color: #1a1819;
padding: 10px 28px;
text-decoration: none;
font-weight: 400;
transition: 0.3s;
display: block;
}
.btn:hover {
background: #1a1819;
color: #fff;
}
/* Discover Section */
.discover-grid {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 40px;
margin-top: 30px;
}
.product-card {
max-width: 1200px;
text-align: left;
}
/* .product-card img {
width: 100%;
} */
.product-card .title {
font-size: 16px;
margin-top: 10px;
}
.product-card .price {
font-weight: 500;
margin-top: 5px;
font-size: 16px;
}
.see-all {
display: block;
text-align: center;
margin-top: 30px;
font-weight: 400;
color: #1a1819;
text-decoration: none;
font-size: 18px;
}
/* -------------------- Responsive -------------------- */
@media (max-width: 992px) {
.heading {
font-size: 28px;
}
.categories-grid,
.discover-grid {
gap: 20px;
}
.rider-sale-banner .sale-content {
padding: 20px;
width: 90%;
}
}
@media (max-width: 768px) {
.categories-grid,
.discover-grid {
flex-direction: column;
align-items: center;
}
.category-item,
.product-card {
width: 100%;
max-width: 280px;
}
.sale-content {
max-width: 85%;
}
}
/* Sellers styling */
.section-title {
text-align: center;
text-transform: uppercase;
font-size: 14px;
letter-spacing: 1px;
color: #B08722;
margin-bottom: 10px;
}
.section-heading {
font-family:'Cormorant';
text-align: center;
font-size: 44px;
font-weight: 500;
margin-bottom: 40px;
color:#1A1819;
}
/* Verified Sellers */
.verified-sellers {
display: flex;
flex-wrap: wrap;
/* gap: 20px; */
justify-content: center;
align-items: center;
}
.seller-card {
flex: 1 1 45%;
background-color: #f6f6f6;
/* text-align: center; */
/* padding: 30px; */
position: relative;
}
.seller-card img {
max-width: 525px;
height: auto;
/* margin-bottom: 20px; */
}
.boot_img{
transform: scaleX(-1);
}
.seller-card h3 {
font-size: 20px;
margin-bottom: 10px;
}
.visit-store {
font-size: 14px;
color: #1a1a1a;
text-decoration: none;
border-bottom: 1px solid;
}
.visit-store:hover {
color: #A08B42;
}
/* Testimonials */
.testimonials {
/* background-color: #fafafa; */
}
.testimonial-wrapper {
display: flex;
flex-wrap: wrap;
gap: 28px;
justify-content: center;
}
.testimonial {
/* background: #fff; */
padding: 10px;
max-width: 443px;
border-radius: 8px;
margin-bottom: 50px;
}
.testimonial img {
object-fit: cover;
float: left;
margin-right: 2px;
}
.testimonial p {
font-family:'Poppins';
font-weight: 400;
font-size: 16px;
/* margin: 10px 0; */
line-height: 1.5;
}
.stars {
color: #FFA500;
margin-top: 10px;
}
.author {
font-size: 14px;
font-style: normal;
color: #555;
margin-top: 10px;
display: flex;
justify-content:space-evenly;
}
/* Responsive */
@media (max-width: 767px) {
.seller-card {
flex: 1 1 100%;
}
.testimonial-wrapper {
flex-direction: column;
align-items: center;
}
}
.verified-sellers-section {
max-width: 1320px;
margin: auto;
display: flex;
/* gap: 30px; */
align-items: stretch;
flex-wrap: wrap;
margin-block: 70px;s
}
.seller-text {
flex: 1 1 100%;
max-width: 300px;
}
.seller-text .label {
font-size: 14px;
font-family:'Poppins';
font-weight:500;
text-transform: uppercase;
color: #B08722;
letter-spacing: 1px;
margin-bottom: 10px;
}
.seller-text h2 {
font-family:'Cormorant';
font-weight:500;
font-size: 44px;
font-weight: normal;
line-height: 1.4;
}
.seller-images {
display: flex;
flex: 1 1 60%;
/* gap: 20px; */
flex-wrap: wrap;
}
.seller-card {
position: relative;
flex: 1 1 45%;
/* border-radius: 6px; */
overflow: hidden;
}
.seller-card img {
/* height: 100%; */
object-fit: cover;
display: block;
}
.seller-card .overlay {
position: absolute;
bottom: 20px;
left: 20px;
color: #1a1a1a;
/* background-color: rgba(255, 255, 255, 0.9); */
padding: 10px 14px;
border-radius: 6px;
max-width: 90%;
}
.seller-card .overlay h3 {
font-family:'Cormorant';
font-weight: 500;
font-size: 36px;
margin-bottom: 4px;
}
.seller-card .overlay a {
font-family:'Poppins';
font-size: 16px;
font-weight: 400;
text-decoration: none;
}
.seller-card .overlay a:hover {
text-decoration: underline;
}
/* Responsive */
@media (max-width: 767px) {
.verified-sellers-section {
flex-direction: column;
}
.seller-images {
flex-direction: column;
}
.seller-card {
flex: 1 1 100%;
}
.seller-text {
max-width: 100%;
margin-bottom: 20px;
}
}
/* home section */
/* Base styles from your provided code remain same */
@media (max-width: 1200px) {
.hero-content h1 {
font-size: 64px;
}
.hero-content {
margin-left: 200px;
max-width: 100%;
}
}
@media (max-width: 992px) {
.hero-container {
flex-direction: column;
align-items: flex-start;
}
.hero-header {
padding: 15px 20px;
flex-direction: column;
align-items: flex-start;
}
.hero-nav {
width: 100%;
flex-direction: column;
}
.nav-menu {
flex-direction: column;
gap: 10px;
margin-top: 10px;
}
.search-container {
margin-top: 15px;
width: 100%;
}
.hero-content {
padding: 0 20px;
margin-left: 0;
margin-top: 50px;
}
.hero-content h1 {
font-size: 48px;
}
.hero-content p {
font-size: 16px;
}
}
@media (max-width: 767px) {
.hero-content h1 {
font-size: 36px;
}
.hero-content p {
font-size: 15px;
}
.hero-button {
width: 100%;
text-align: center;
padding: 12px;
font-size: 15px;
}
.dropdown {
position: relative;
box-shadow: none;
background-color: #f9f9f9;
}
.dropdown li a {
padding: 8px 12px;
font-size: 14px;
}
.nav-menu li {
width: 100%;
}
}
@media (max-width: 480px) {
.hero-content h1 {
font-size: 28px;
}
.hero-content p {
font-size: 14px;
}
.hero-button {
font-size: 14px;
}
.search-container img {
width: 20px;
height: 20px;
}
}
</style>
<section class="hero-section">
<div class="hero-content">
<h1><?php echo get_field('banner_title'); ?></h1>
<p><?php echo get_field('banner_description');?></p>
<a href="<?php echo esc_url(get_field('banner_cta')); ?>" class="hero-button">
<?php echo esc_html(get_field('banner_cta_context')); ?>
</a>
<?php $banner = get_field('banner_image'); ?>
</div>
</section>
<section class="home-section">
<!-- Categories Section -->
<?php
$terms = get_field('accessories');
if ( $terms && is_array($terms) ) : ?>
<div class="categories-section">
<p class="subheading"><?php echo esc_html(get_field('section_subtitle')); ?></p>
<h2 class="heading"><?php echo esc_html(get_field('section_title')); ?></h2>
<div class="categories-grid">
<?php foreach ( $terms as $term ) :
if ( is_object($term) ) {
$term_id = $term->term_id;
$term_name = $term->name;
} else {
$term_id = $term;
$term_obj = get_term($term_id, 'product_cat');
$term_name = $term_obj ? $term_obj->name : '';
}
$thumbnail_id = get_term_meta($term_id, 'thumbnail_id', true);
$image_url = wp_get_attachment_url($thumbnail_id);
?>
<div class="category-item">
<img src="<?php echo esc_url($image_url ?: get_stylesheet_directory_uri() . '/assets/images/default-category.png'); ?>" alt="<?php echo esc_attr($term_name); ?>" />
<p><?php echo esc_html($term_name); ?></p>
</div>
<?php endforeach; ?>
</div>
</div>
<?php else: ?>
<p>No categories selected.</p>
<?php endif; ?>
<!-- Rider Sale Banner -->
<?php
$banner1 = get_field('banner_image1');
$banner2 = get_field('banner_image2');
?>
<div class="rider-sale-banner">
<img src="<?php echo esc_url(get_field('banner_image1')); ?>" alt="Banner 1">
<img src="<?php echo esc_url(get_field('banner_image2')); ?>" alt="Banner 2">
<div class="sale-content">
<p class="discount"><?php echo get_field('sale_banner_heading') ?></p>
<h3><?php echo get_field('sale_title') ?></h3>
<p><?php echo get_field('sale_content') ?></p>
<a href="<?php echo esc_url(get_field('sale_banner')); ?>" class="btn">
<?php echo esc_html(get_field('sale_button_context')); ?>
</a>
</div>
</div>
<!-- Discover More Section -->
<?php
$discover_cat = get_field('discover_category'); // ACF taxonomy field
$args = array(
'post_type' => 'product',
'posts_per_page' => 4,
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => 'discover_me', // <-- Your category slug
),
),
);
$query = new WP_Query($args);
?>
<div class="discover-grid">
<?php if ($query->have_posts()) : ?>
<?php while ($query->have_posts()) : $query->the_post(); global $product; ?>
<div class="product-card">
<a href="<?php the_permalink(); ?>">
<?php if (has_post_thumbnail()) : ?>
<?php the_post_thumbnail('medium'); ?>
<?php else : ?>
<img src="<?php echo get_stylesheet_directory_uri(); ?>/assets/images/default-product.png" alt="No Image">
<?php endif; ?>
</a>
<p class="title"><?php the_title(); ?></p>
<p class="price"><?php echo $product->get_price_html(); ?></p>
</div>
<?php endwhile; wp_reset_postdata(); ?>
<?php else : ?>
<p>No products found in this category.</p>
<?php endif; ?>
</div>
</section>
<section class="apparel">
<div class="rider-banner">
<p class="subheading"><?php echo esc_html(get_field('newness_subheading')); ?></p>
<h2 class="heading"><?php echo esc_html(get_field('newness_title')); ?></h2>
<img src="<?php echo esc_url(get_field('apparel_image')); ?>" alt="Banner 1" class="image fluid">
</div>
</section>
<section class="verified-sellers-section">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 4,
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => 'top_picks',
),
),
);
$query = new WP_Query($args);
?>
<div class="discover-section">
<p class="subheading"><?php echo get_field('top_picks_subheading'); ?></p>
<h2 class="heading"><?php echo get_field('top_pick_title'); ?></h2>
<div class="discover-grid">
<?php if ($query->have_posts()) : ?>
<?php while ($query->have_posts()) : $query->the_post(); global $product; ?>
<div class="product-card">
<a href="<?php the_permalink(); ?>">
<?php if (has_post_thumbnail()) : ?>
<?php the_post_thumbnail('medium'); ?>
<?php else : ?>
<img src="<?php echo get_stylesheet_directory_uri(); ?>/assets/images/default-product.png" alt="No Image">
<?php endif; ?>
</a>
<p class="title"><?php the_title(); ?></p>
<p class="price"><?php echo $product->get_price_html(); ?></p>
</div>
<?php endwhile; wp_reset_postdata(); ?>
<?php else : ?>
<p>No products found in this category.</p>
<?php endif; ?>
</div>
</div>
<!-- Left Text Column -->
<div class="seller-text">
<div class="label"><?php echo esc_html(get_field('seller_subheading')); ?></div>
<h2><?php echo esc_html(get_field('seller_title')); ?></h2>
</div>
<!-- Right Image Cards -->
<div class="seller-images">
<div class="seller-card">
<img src="<?php echo esc_url(get_field('seller_image_1')); ?>" alt="Fedora Hats" class="img-fluid">
<div class="overlay">
<h3><?php echo esc_html(get_field('seller_image1_title')); ?></h3>
<a href="<?php echo get_field('seller_image_link1'); ?>">Visit Store →</a>
</div>
</div>
<div class="seller-card">
<img src="<?php echo esc_url(get_field('seller_image_2')); ?>" class="img-fluid boot_img" alt="Fedora boots">
<div class="overlay">
<h3><?php echo esc_html(get_field('seller_image2_title')); ?></h3>
<a href="<?php echo get_field('seller_image_link2'); ?>">Visit Store →</a>
</div>
</div>
</div>
</section>
<!-- Testimonials Section -->
<section class="testimonials">
<div class="section-title"><?php echo esc_html(get_field('testimonial_subheading')); ?></div>
<div class="section-heading"><?php echo esc_html(get_field('testimonial_title')); ?></div>
<div class="testimonial-wrapper multiple-items">
<?php
$testimonials = new WP_Query(array(
'post_type' => 'testimonial',
'posts_per_page' => 4,
));
if ($testimonials->have_posts()) :
while ($testimonials->have_posts()) : $testimonials->the_post();
$testimonial_content = get_field('testimonial_content');
$rating = $testimonial_content['rating'] ?? 5;
$image_url = get_the_post_thumbnail_url(get_the_ID(), 'medium'); // get featured image
?>
<div class="testimonial">
<?php if ($image_url): ?>
<img src="<?php echo esc_url($image_url); ?>" alt="<?php the_title_attribute(); ?>">
<?php endif; ?>
<div class="stars"><?php echo str_repeat('★', intval($rating)); ?></div>
<p><?php the_content(); ?></p>
<div class="author">- <?php the_title(); ?></div>
</div>
<?php
endwhile;
wp_reset_postdata();
endif;
?>
</div>
</section>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.min.js"></script>
<script>
$(document).ready(function(){
$('.multiple-items').slick({
infinite: true,
slidesToShow: 3,
slidesToScroll: 2,
arrows: false,
dots: true,
responsive: [
{
breakpoint: 1024,
settings: {
slidesToShow: 3,
}
},
{
breakpoint: 768,
settings: {
slidesToShow: 2,
}
}
]
});
});
</script>
<?php
get_footer();
?>