Home / Comments / Jadecita Web
Duplicate Snippet

Embed Snippet on Your Site

Jadecita Web

Code Preview
php
<?php
<?php
/*
Template Name: Home Page
*/
get_header(); 
// TEXTOS - Inglés por defecto, Español como alternativa
$texts = array(
    'en' => array(
        'view_research'     => 'View My Research',
        'contact'           => 'Get in Touch',
        'featured_projects' => 'Featured Projects',
        'projects_desc'     => 'Current research in environmental science and natural resource management',
        'latest_posts'      => 'Latest Posts',
        'posts_desc'        => 'Science communication and research insights',
        'view_all_projects' => 'View All Projects',
        'view_all_posts'    => 'View All Posts',
        'newsletter'        => 'Subscribe to Newsletter',
        'newsletter_desc'   => 'Get updates on environmental research and projects',
        'email_placeholder' => 'Your email address',
        'subscribe'         => 'Subscribe',
        'years'             => 'Years Experience',
        'publications'      => 'Publications',
        'projects'          => 'Projects',
        'countries'         => 'Countries',
    ),
    'es' => array(
        'view_research'     => 'Ver Mi Investigación',
        'contact'           => 'Contactar',
        'featured_projects' => 'Proyectos Destacados',
        'projects_desc'     => 'Investigación actual en ciencias ambientales y gestión de recursos naturales',
        'latest_posts'      => 'Últimas Publicaciones',
        'posts_desc'        => 'Divulgación científica y reflexiones sobre investigación',
        'view_all_projects' => 'Ver Todos los Proyectos',
        'view_all_posts'    => 'Ver Todas las Publicaciones',
        'newsletter'        => 'Suscríbete al Newsletter',
        'newsletter_desc'   => 'Recibe actualizaciones sobre investigación ambiental',
        'email_placeholder' => 'Tu correo electrónico',
        'subscribe'         => 'Suscribirse',
        'years'             => 'Años de Experiencia',
        'publications'      => 'Publicaciones',
        'projects'          => 'Proyectos',
        'countries'         => 'Países',
    )
);
$lang = is_spanish() ? 'es' : 'en'; // INGLÉS ES DEFAULT
$t = $texts[$lang];
$tagline = get_theme_mod(is_spanish() ? 'hero_tagline_es' : 'hero_tagline_en', $texts[$lang]['view_research']);
?>
<!-- HERO SECTION -->
<section class="hero-section">
    <div class="container hero-content">
        <h1 class="hero-title"><?php bloginfo('name'); ?></h1>
        <p class="hero-subtitle"><?php echo esc_html($tagline); ?></p>
        <div class="hero-buttons">
            <a href="<?php echo get_post_type_archive_link('projects'); ?>" class="btn btn-primary">
                <?php echo $t['view_research']; ?>
            </a>
            <a href="<?php echo get_permalink(get_page_by_path(is_spanish() ? 'contacto' : 'contact')); ?>" class="btn btn-secondary">
                <?php echo $t['contact']; ?>
            </a>
        </div>
    </div>
</section>
<!-- STATS SECTION -->
<section class="stats-section">
    <div class="container">
        <div class="stats-grid">
            <?php for ($i = 1; $i <= 4; $i++) : 
                $number = get_theme_mod("stat_{$i}_number", ($i == 1) ? '10+' : (($i == 2) ? '25' : (($i == 3) ? '15' : '5')));
                $label = get_theme_mod("stat_{$i}_label_$lang", $t[($i == 1) ? 'years' : (($i == 2) ? 'publications' : (($i == 3) ? 'projects' : 'countries'))]);
            ?>
                <div class="stat-item">
                    <h3><?php echo esc_html($number); ?></h3>
                    <p><?php echo esc_html($label); ?></p>
                </div>
            <?php endfor; ?>
        </div>
    </div>
</section>
<!-- FEATURED PROJECTS -->
<section class="section">
    <div class="container">
        <div class="section-title">
            <h2><?php echo $t['featured_projects']; ?></h2>
            <p><?php echo $t['projects_desc']; ?></p>
        </div>
        
        <?php echo do_shortcode('[projects count="3"]'); ?>
        
        <div class="text-center mt-2">
            <a href="<?php echo get_post_type_archive_link('projects'); ?>" class="btn btn-primary">
                <?php echo $t['view_all_projects']; ?>
            </a>
        </div>
    </div>
</section>
<!-- LATEST BLOG POSTS -->
<section class="section" style="background: var(--color-white);">
    <div class="container">
        <div class="section-title">
            <h2><?php echo $t['latest_posts']; ?></h2>
            <p><?php echo $t['posts_desc']; ?></p>
        </div>
        
        <div class="blog-grid">
            <?php
            $blog_posts = new WP_Query(array('posts_per_page' => 3));
            while ($blog_posts->have_posts()) : $blog_posts->the_post(); ?>
                <article class="blog-card">
                    <?php if (has_post_thumbnail()) : ?>
                        <a href="<?php the_permalink(); ?>">
                            <?php the_post_thumbnail('medium_large', array('class' => 'blog-image')); ?>
                        </a>
                    <?php endif; ?>
                    <div class="blog-content">
                        <div class="blog-meta">
                            <span><i class="far fa-calendar"></i> <?php echo get_the_date(); ?></span>
                        </div>
                        <h3 class="blog-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                        <?php the_excerpt(); ?>
                        <a href="<?php the_permalink(); ?>" class="read-more">
                            <?php echo is_spanish() ? 'Leer más' : 'Read more'; ?> <i class="fas fa-arrow-right"></i>
                        </a>
                    </div>
                </article>
            <?php endwhile; wp_reset_postdata(); ?>
        </div>
        
        <div class="text-center mt-2">
            <a href="<?php echo get_permalink(get_option('page_for_posts')); ?>" class="btn btn-primary">
                <?php echo $t['view_all_posts']; ?>
            </a>
        </div>
    </div>
</section>
<!-- NEWSLETTER -->
<section class="section" style="background: var(--color-forest-green); color: var(--color-white);">
    <div class="container text-center">
        <h2 style="color: var(--color-white);"><?php echo $t['newsletter']; ?></h2>
        <p><?php echo $t['newsletter_desc']; ?></p>
        
        <form style="max-width: 500px; margin: 2rem auto 0;" action="#" method="post">
            <div class="form-group" style="display: flex; gap: 1rem; flex-wrap: wrap;">
                <input type="email" name="email" placeholder="<?php echo $t['email_placeholder']; ?>" required style="flex: 1; min-width: 250px;">
                <button type="submit" class="btn btn-primary" style="background: var(--color-warm-sand);">
                    <?php echo $t['subscribe']; ?>
                </button>
            </div>
        </form>
    </div>
</section>
<?php get_footer(); ?>

Comments

Add a Comment