Files
powerservice/wp-content/themes/powerservices/index.php
T
2026-10-19 12:45:45 -06:00

174 lines
8.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php get_header(); ?>
<main id="main-content">
<section id="blog-hero" class="relative isolate flex min-h-[575px] overflow-hidden bg-color-5 text-white md:min-h-[440px]" aria-labelledby="blog-hero-title">
<?php echo wp_get_attachment_image( 1675, 'full', false, array(
'class' => 'absolute inset-0 -z-10 h-full w-full object-cover object-center',
'alt' => '',
'loading' => 'eager',
'fetchpriority' => 'high',
'sizes' => '100vw',
'aria-hidden' => 'true',
) ); ?>
<div class="container flex min-h-[575px] items-center px-[50px] lg:px-8 md:min-h-[440px] md:w-[85%] md:px-0" data-scroll-reveal>
<h1 id="blog-hero-title" class="max-w-[700px] -translate-y-[5px] text-[50px] font-black uppercase leading-[1.2] md:w-full md:max-w-none md:-translate-y-[10px] md:text-[22px]">Innovaciones y soluciones en ingeniería hidráulica y energética</h1>
</div>
</section>
<section id="articulos" class="scroll-mt-32 bg-white py-[50px] text-color-5" aria-label="Artículos del blog">
<div class="container grid grid-cols-[minmax(0,811fr)_minmax(0,319fr)] gap-[50px] px-[50px] lg:gap-8 lg:px-8 md:w-[85%] md:grid-cols-1 md:px-0">
<div>
<?php
$paged = max( 1, get_query_var( 'paged' ), get_query_var( 'page' ) );
$blog_query_args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 3,
'paged' => $paged,
'ignore_sticky_posts' => true,
);
if ( is_category() ) {
$blog_query_args['cat'] = get_queried_object_id();
}
$blog_posts = new WP_Query( $blog_query_args );
?>
<?php if ( $blog_posts->have_posts() ) : ?>
<div class="space-y-[45px]">
<?php while ( $blog_posts->have_posts() ) : $blog_posts->the_post(); ?>
<?php
$post_categories = get_the_category();
$primary_category = ! empty( $post_categories ) ? $post_categories[0] : null;
$excerpt_source = has_excerpt()
? get_the_excerpt()
: wp_strip_all_tags( strip_shortcodes( get_the_content() ) );
$post_excerpt = wp_trim_words( $excerpt_source, 55, ' […]' );
?>
<article id="post-<?php the_ID(); ?>" <?php post_class( 'text-center' ); ?>>
<?php if ( $primary_category ) : ?>
<a class="mx-auto mb-[15px] block min-h-[30px] w-[470px] max-w-full bg-[#f8b334] px-[30px] py-[6px] text-[14px] font-semibold uppercase leading-[18px] text-white" href="<?php echo esc_url( get_category_link( $primary_category->term_id ) ); ?>">
<?php echo esc_html( $primary_category->name ); ?>
</a>
<?php endif; ?>
<h2 class="mb-5 text-[32px] font-black leading-[1.328] text-[#333333]">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h2>
<?php if ( has_post_thumbnail() ) : ?>
<a class="block aspect-[811/308] w-full overflow-hidden" href="<?php the_permalink(); ?>" aria-label="<?php echo esc_attr( get_the_title() ); ?>">
<?php the_post_thumbnail( 'large', array(
'class' => 'h-full w-full object-cover object-center',
'loading' => 'lazy',
'sizes' => '(max-width: 767px) 85vw, 64vw',
) ); ?>
</a>
<?php endif; ?>
<p class="mt-6 text-[16px] leading-[1.2] text-black"><?php echo esc_html( $post_excerpt ); ?></p>
<a class="mt-5 inline-block text-[19px] font-semibold uppercase leading-[1.2] text-[#d1d1d1]" href="<?php the_permalink(); ?>">Leer artículo</a>
</article>
<?php endwhile; ?>
</div>
<?php if ( $blog_posts->max_num_pages > 1 ) : ?>
<?php
$total_pages = (int) $blog_posts->max_num_pages;
$window_start = max( 1, min( $paged - 1, $total_pages - 2 ) );
$window_end = min( $total_pages, $window_start + 2 );
?>
<nav class="mt-[45px] flex justify-center gap-[6px]" aria-label="Paginación del blog">
<?php if ( $paged > 1 ) : ?>
<a class="inline-flex h-[35px] w-[35px] items-center justify-center bg-white text-[15px] font-semibold" href="<?php echo esc_url( get_pagenum_link( 1 ) ); ?>" aria-label="Primera página">«</a>
<a class="inline-flex h-[35px] w-[35px] items-center justify-center bg-white text-[15px] font-semibold" href="<?php echo esc_url( get_pagenum_link( $paged - 1 ) ); ?>" aria-label="Página anterior">‹</a>
<?php endif; ?>
<?php for ( $page_number = $window_start; $page_number <= $window_end; $page_number++ ) : ?>
<?php if ( $page_number === $paged ) : ?>
<span class="inline-flex h-[35px] w-[35px] items-center justify-center bg-[#dadada] text-[15px] font-semibold text-white" aria-current="page"><?php echo esc_html( $page_number ); ?></span>
<?php else : ?>
<a class="inline-flex h-[35px] w-[35px] items-center justify-center bg-white text-[15px] font-semibold" href="<?php echo esc_url( get_pagenum_link( $page_number ) ); ?>"><?php echo esc_html( $page_number ); ?></a>
<?php endif; ?>
<?php endfor; ?>
<?php if ( $paged < $total_pages ) : ?>
<a class="inline-flex h-[35px] w-[35px] items-center justify-center bg-white text-[15px] font-semibold" href="<?php echo esc_url( get_pagenum_link( $paged + 1 ) ); ?>" aria-label="Página siguiente">›</a>
<a class="inline-flex h-[35px] w-[35px] items-center justify-center bg-white text-[15px] font-semibold" href="<?php echo esc_url( get_pagenum_link( $total_pages ) ); ?>" aria-label="Última página">»</a>
<?php endif; ?>
</nav>
<?php endif; ?>
<?php else : ?>
<p class="text-center text-[19px]">No hay artículos publicados.</p>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
</div>
<aside class="border-l border-[#e5e5e5] pl-[50px] lg:pl-8 md:hidden" aria-label="Navegación del blog">
<section class="pb-[150px]" aria-labelledby="blog-categorias-title">
<h2 id="blog-categorias-title" class="mb-2 text-[21px] font-bold uppercase leading-[1.2] text-black">Categorías</h2>
<ul class="space-y-[10px] text-[17px] leading-[1.35] text-black">
<?php
$blog_categories = get_categories(
array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => true,
)
);
foreach ( $blog_categories as $category ) :
?>
<li><a class="transition-colors hover:text-[#f8b334]" href="<?php echo esc_url( get_category_link( $category->term_id ) ); ?>"><?php echo esc_html( $category->name ); ?></a></li>
<?php endforeach; ?>
</ul>
</section>
<section class="border-t border-[#e5e5e5] pt-8" aria-labelledby="blog-recientes-title">
<h2 id="blog-recientes-title" class="mb-2 text-[21px] font-bold uppercase leading-[1.2] text-black">Artículos recientes</h2>
<?php
$recent_posts = new WP_Query(
array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 5,
'ignore_sticky_posts' => true,
'no_found_rows' => true,
)
);
?>
<?php if ( $recent_posts->have_posts() ) : ?>
<ul>
<?php while ( $recent_posts->have_posts() ) : $recent_posts->the_post(); ?>
<li class="grid min-h-[92px] grid-cols-[36px_minmax(0,1fr)] items-start gap-[9px] py-[7px]">
<a class="mt-1 block h-9 w-9 overflow-hidden" href="<?php the_permalink(); ?>" tabindex="-1" aria-hidden="true">
<?php if ( has_post_thumbnail() ) : ?>
<?php the_post_thumbnail( 'thumbnail', array(
'class' => 'h-9 w-9 object-cover',
'alt' => '',
'loading' => 'lazy',
) ); ?>
<?php endif; ?>
</a>
<div>
<a class="block text-[15px] font-black leading-[1.2] text-black transition-colors hover:text-[#f8b334]" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<time class="mt-3 block text-[11px] leading-[1.3] text-black" datetime="<?php echo esc_attr( get_the_date( DATE_W3C ) ); ?>"><?php echo esc_html( get_the_date( 'j F, Y - g:i a' ) ); ?></time>
</div>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
</section>
</aside>
</div>
</section>
</main>
<?php get_footer(); ?>