Files
gustavoo-me/wp-content/themes/gustavoo-portfolio/single.php
T

139 lines
5.8 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
/**
* Single blog post template.
*
* @package Gustavo_Portfolio
*/
get_header();
while ( have_posts() ) :
the_post();
?>
<main id="primary" class="site-main single-post-main">
<header class="entry-hero">
<div class="site-shell entry-hero__inner">
<nav class="entry-breadcrumbs" aria-label="<?php esc_attr_e( 'Navegação estrutural', 'gustavoo-portfolio' ); ?>">
<a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php esc_html_e( 'Início', 'gustavoo-portfolio' ); ?></a>
<span aria-hidden="true"></span>
<a href="<?php echo esc_url( gustavoo_portfolio_get_blog_url() ); ?>"><?php esc_html_e( 'Últimas notícias', 'gustavoo-portfolio' ); ?></a>
<?php $gustavoo_breadcrumb_categories = get_the_category(); ?>
<?php if ( ! empty( $gustavoo_breadcrumb_categories ) ) : ?>
<span aria-hidden="true"></span>
<a href="<?php echo esc_url( get_category_link( $gustavoo_breadcrumb_categories[0] ) ); ?>"><?php echo esc_html( $gustavoo_breadcrumb_categories[0]->name ); ?></a>
<?php endif; ?>
</nav>
<?php $gustavoo_categories = get_the_category(); ?>
<?php if ( ! empty( $gustavoo_categories ) ) : ?>
<a class="entry-category-badge" href="<?php echo esc_url( get_category_link( $gustavoo_categories[0] ) ); ?>"><?php echo esc_html( $gustavoo_categories[0]->name ); ?></a>
<?php endif; ?>
<?php the_title( '<h1 class="entry-hero__title">', '</h1>' ); ?>
</div>
</header>
<div class="site-shell entry-post-meta">
<div class="entry-post-meta__author">
<strong><?php echo esc_html( get_the_author() ); ?></strong>
<span aria-hidden="true">·</span>
<span><?php esc_html_e( 'Publicado em', 'gustavoo-portfolio' ); ?> <?php echo esc_html( get_the_date() ); ?></span>
<span aria-hidden="true">·</span>
<span><?php echo esc_html( gustavoo_portfolio_reading_time() ); ?></span>
</div>
<?php gustavoo_portfolio_post_share_links(); ?>
</div>
<?php if ( has_post_thumbnail() ) : ?>
<figure class="entry-featured-image">
<?php the_post_thumbnail( 'full', array( 'class' => 'entry-featured-image__image' ) ); ?>
</figure>
<?php endif; ?>
<div class="site-shell article-layout article-layout--single">
<article id="post-<?php the_ID(); ?>" <?php post_class( 'article article--single' ); ?>>
<div class="entry-content prose">
<?php the_content(); ?>
<?php
wp_link_pages(
array(
'before' => '<nav class="page-links" aria-label="' . esc_attr__( 'Páginas deste artigo', 'gustavoo-portfolio' ) . '"><span>' . esc_html__( 'Páginas:', 'gustavoo-portfolio' ) . '</span>',
'after' => '</nav>',
)
);
?>
</div>
<footer class="entry-footer">
<?php gustavoo_portfolio_entry_terms(); ?>
</footer>
<?php
$gustavoo_categories = get_the_category();
?>
<section class="post-share-panel" aria-labelledby="post-share-title">
<h2 id="post-share-title" class="post-share-panel__title"><?php esc_html_e( 'Compartilhar:', 'gustavoo-portfolio' ); ?></h2>
<?php gustavoo_portfolio_post_share_links( 'post-share-panel__links' ); ?>
</section>
<?php if ( ! empty( $gustavoo_categories ) ) : ?>
<?php
$gustavoo_related_posts = new WP_Query(
array(
'category__in' => wp_list_pluck( $gustavoo_categories, 'term_id' ),
'post__not_in' => array( get_the_ID() ),
'posts_per_page' => 3,
'ignore_sticky_posts' => true,
'orderby' => 'date',
'order' => 'DESC',
)
);
?>
<?php if ( $gustavoo_related_posts->have_posts() ) : ?>
<section class="related-posts" aria-labelledby="related-posts-title">
<div class="related-posts__heading"><span></span><h2 id="related-posts-title"><?php esc_html_e( 'Relacionadas', 'gustavoo-portfolio' ); ?></h2><span></span></div>
<div class="related-posts__grid">
<?php while ( $gustavoo_related_posts->have_posts() ) : $gustavoo_related_posts->the_post(); ?>
<article <?php post_class( 'related-post' ); ?>>
<a class="related-post__link" href="<?php the_permalink(); ?>">
<?php if ( has_post_thumbnail() ) : ?>
<?php the_post_thumbnail( 'gustavoo-post-card', array( 'class' => 'related-post__image', 'loading' => 'lazy', 'decoding' => 'async' ) ); ?>
<?php endif; ?>
<h3 class="related-post__title"><?php the_title(); ?></h3>
</a>
</article>
<?php endwhile; ?>
</div>
</section>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
<?php $gustavoo_previous_post = get_previous_post(); ?>
<?php $gustavoo_next_post = get_next_post(); ?>
<?php if ( $gustavoo_previous_post || $gustavoo_next_post ) : ?>
<nav class="post-navigation post-navigation--editorial" aria-label="<?php esc_attr_e( 'Navegação entre artigos', 'gustavoo-portfolio' ); ?>">
<div class="nav-links">
<?php if ( $gustavoo_previous_post ) : ?>
<a class="nav-previous" href="<?php echo esc_url( get_permalink( $gustavoo_previous_post ) ); ?>"><span class="nav-subtitle">← <?php esc_html_e( 'Anterior', 'gustavoo-portfolio' ); ?></span><span class="nav-title"><?php echo esc_html( get_the_title( $gustavoo_previous_post ) ); ?></span></a>
<?php endif; ?>
<?php if ( $gustavoo_next_post ) : ?>
<a class="nav-next" href="<?php echo esc_url( get_permalink( $gustavoo_next_post ) ); ?>"><span class="nav-subtitle"><?php esc_html_e( 'Próximo', 'gustavoo-portfolio' ); ?> →</span><span class="nav-title"><?php echo esc_html( get_the_title( $gustavoo_next_post ) ); ?></span></a>
<?php endif; ?>
</div>
</nav>
<?php endif; ?>
<?php if ( comments_open() || get_comments_number() ) {
comments_template();
}
?>
</article>
<?php get_sidebar(); ?>
</div>
</main>
<?php
endwhile;
get_footer();