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

164 lines
7.3 KiB
PHP

<?php
/**
* Plantilla para el detalle de las entradas del blog.
*
* @package PowerServices
*/
get_header();
?>
<main id="main-content">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : ?>
<?php
the_post();
$post_id = get_the_ID();
$post_categories = get_the_category( $post_id );
$category_ids = wp_get_post_categories( $post_id );
$primary_category = ! empty( $post_categories ) ? $post_categories[0] : null;
?>
<section class="bg-white pb-[60px] pt-[40px] text-color-5">
<div class="container grid grid-cols-[minmax(0,861fr)_minmax(0,319fr)] px-[50px] lg:px-8 md:w-[85%] md:grid-cols-1 md:px-0">
<article <?php post_class( 'min-w-0 pb-[44px] pr-[50px] pt-[50px] md:pr-0' ); ?>>
<?php if ( $primary_category ) : ?>
<a class="mx-auto mb-[15px] block w-[470px] max-w-full bg-[#f8b334] px-[30px] py-[6px] text-center text-[14px] font-bold uppercase leading-[18.5px] text-white" href="<?php echo esc_url( get_category_link( $primary_category->term_id ) ); ?>">
<?php echo esc_html( $primary_category->name ); ?>
</a>
<?php endif; ?>
<h1 class="mb-[20px] text-[32px] font-black leading-[1.328] text-[#333333]">
<?php the_title(); ?>
</h1>
<?php if ( has_post_thumbnail() ) : ?>
<figure class="aspect-[811/308] w-full overflow-hidden">
<?php the_post_thumbnail( 'full', array( 'class' => 'h-full w-full object-cover', 'loading' => 'eager' ) ); ?>
</figure>
<?php endif; ?>
<div class="ps-post-content mt-6 text-[16px] leading-[1.425] text-black md:mt-11 [&_a]:font-semibold [&_a]:text-[#d09d24] [&_blockquote]:my-5 [&_blockquote]:border-l-4 [&_blockquote]:border-[#f8b334] [&_blockquote]:pl-5 [&_h2]:mb-[10px] [&_h2]:mt-9 [&_h2]:text-[24px] [&_h2]:font-black [&_h2]:leading-[1.2] [&_h3]:mb-2 [&_h3]:mt-9 [&_h3]:text-[24px] [&_h3]:font-bold [&_h3]:leading-[1.2] [&_img]:h-auto [&_img]:max-w-full [&_ol]:my-4 [&_ol]:list-decimal [&_ol]:pl-6 [&_p]:my-[14px] [&_table]:mb-5 [&_table]:w-full [&_table]:table-fixed [&_table]:border-collapse [&_table]:text-[13px] [&_td]:break-words [&_td]:border [&_td]:border-[#dedede] [&_td]:p-3 [&_th]:border [&_th]:border-[#dedede] [&_th]:bg-[#f8b334] [&_th]:p-3 [&_th]:text-left [&_th]:font-bold [&_ul]:my-4 [&_ul]:list-disc [&_ul]:pl-6 md:[&_h2]:text-[22px] md:[&_h3]:text-[22px]">
<?php the_content(); ?>
</div>
</article>
<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="single-blog-categorias-title">
<h2 id="single-blog-categorias-title" class="mb-2 text-[21px] font-bold uppercase leading-[1.2] text-black">Categorías</h2>
<?php
$blog_categories = get_categories(
array(
'hide_empty' => true,
'orderby' => 'name',
'order' => 'ASC',
)
);
?>
<?php if ( $blog_categories ) : ?>
<ul class="space-y-[10px] text-[17px] leading-[1.35] text-black">
<?php foreach ( $blog_categories as $blog_category ) : ?>
<li>
<a class="transition-colors hover:text-[#f8b334]" href="<?php echo esc_url( get_category_link( $blog_category->term_id ) ); ?>">
<?php echo esc_html( $blog_category->name ); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</section>
<section class="border-t border-[#e5e5e5] pt-8" aria-labelledby="single-blog-recientes-title">
<h2 id="single-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() ) : ?>
<?php $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>
<?php
$related_posts = new WP_Query(
array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 2,
'post__not_in' => array( $post_id ),
'category__in' => $category_ids,
'ignore_sticky_posts' => true,
)
);
?>
<?php if ( $related_posts->have_posts() ) : ?>
<section class="container mt-[95px] px-[50px] lg:px-8 md:mt-[65px] md:w-[85%] md:px-0" aria-labelledby="related-posts-title">
<h2 id="related-posts-title" class="mb-[18px] text-[18px] font-normal leading-[29px] text-[#777777]">VER MÁS</h2>
<div class="grid max-w-[768px] grid-cols-2 gap-10 px-[10px] md:max-w-none md:grid-cols-1 md:gap-8 md:px-0">
<?php while ( $related_posts->have_posts() ) : ?>
<?php $related_posts->the_post(); ?>
<article class="text-center">
<a class="block aspect-[1.565] w-full overflow-hidden" href="<?php the_permalink(); ?>" aria-label="<?php echo esc_attr( get_the_title() ); ?>">
<?php if ( has_post_thumbnail() ) : ?>
<?php the_post_thumbnail( 'large', array( 'class' => 'h-full w-full object-cover' ) ); ?>
<?php endif; ?>
</a>
<h3 class="mt-[10px] text-[16px] font-black leading-[1.25] text-[#333333]">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h3>
<p class="mx-auto mt-[10px] text-[12px] font-medium leading-[1.5] text-[#333333]">
<?php echo esc_html( wp_trim_words( wp_strip_all_tags( strip_shortcodes( get_the_content() ) ), 18, '' ) ); ?>
</p>
<a class="mt-2 inline-block text-[12px] font-bold uppercase text-[#d09d24]" href="<?php the_permalink(); ?>">CONTINUAR LEYENDO</a>
</article>
<?php endwhile; ?>
</div>
</section>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
</section>
<?php endwhile; ?>
<?php else : ?>
<section class="container py-24 text-center">
<h1 class="text-3xl font-black text-[#333333]">Entrada no encontrada</h1>
</section>
<?php endif; ?>
</main>
<?php get_footer(); ?>