File: /var/www/viitorx.stgviitor.com/wp-content/themes/viitorx/template-parts/content-single-post.php
<?php
/**
* @package ViitorX
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$related = new WP_Query(
array(
'post_type' => 'post',
'posts_per_page' => 3,
'post__not_in' => array( get_the_ID() ),
'ignore_sticky_posts' => true,
'no_found_rows' => true,
)
);
$blog_list_url = viitorx_get_page_url_by_template( 'template-blog-listing.php' );
$contact_url = viitorx_get_page_url_by_template( 'template-contact-us.php' );
$viitorx_share_permalink = wp_get_canonical_url( get_the_ID() ) ?: get_permalink();
$viitorx_share_title = wp_strip_all_tags( get_the_title() );
$viitorx_share_facebook = 'https://www.facebook.com/sharer.php?' . http_build_query( array( 'u' => $viitorx_share_permalink ), '', '&', PHP_QUERY_RFC3986 );
$viitorx_share_x = add_query_arg( array( 'url' => $viitorx_share_permalink, 'text' => $viitorx_share_title ), 'https://twitter.com/intent/tweet' );
$viitorx_share_linkedin = add_query_arg( 'url', $viitorx_share_permalink, 'https://www.linkedin.com/sharing/share-offsite/' );
$viitorx_share_pinterest = add_query_arg( array( 'url' => $viitorx_share_permalink, 'description' => $viitorx_share_title ), 'https://www.pinterest.com/pin/create/button/' );
?>
<div
class="viitorx-blog-single-page"
data-share-url="<?php echo esc_url( $viitorx_share_permalink ); ?>"
data-share-title="<?php echo esc_attr( wp_strip_all_tags( get_the_title() ) ); ?>"
>
<article id="post-<?php the_ID(); ?>" <?php post_class( 'viitorx-blog-single-article' ); ?>>
<section class="blog-hero section-reveal--visible" aria-label="<?php esc_attr_e( 'Article hero', 'viitorx' ); ?>" data-section-reveal>
<?php get_template_part( 'template-parts/hero-wordmark' ); ?>
<div class="blog-hero__media" aria-hidden="true">
<?php
if ( has_post_thumbnail() ) {
echo get_the_post_thumbnail(
get_the_ID(),
'full',
array(
'class' => 'blog-hero__media-img',
'alt' => '',
'decoding' => 'async',
'fetchpriority' => 'high',
'sizes' => '100vw',
)
);
}
?>
</div>
<div class="blog-hero__overlay" aria-hidden="true"></div>
<div class="container blog-hero__inner">
<h1 class="blog-hero__title"><?php
$viitorx_hero_title = get_the_title();
if ( false !== strpos( $viitorx_hero_title, ':' ) ) {
$viitorx_title_parts = explode( ':', $viitorx_hero_title, 2 );
echo '<span class="blog-hero__title-line">' . esc_html( trim( $viitorx_title_parts[0] ) ) . ':</span><br>';
echo '<span class="blog-hero__title-line">' . esc_html( trim( $viitorx_title_parts[1] ) ) . '</span>';
} else {
echo esc_html( $viitorx_hero_title );
}
?></h1>
</div>
</section>
<section class="blog-details" aria-label="<?php esc_attr_e( 'Blog content', 'viitorx' ); ?>" data-section-reveal>
<div class="container blog-details__inner">
<div class="blog-article">
<?php if ( has_excerpt() ) : ?>
<p class="blog-article__intro"><?php echo wp_kses_post( get_the_excerpt() ); ?></p>
<div class="divider" aria-hidden="true"></div>
<?php endif; ?>
<div id="blog-article-body" class="blog-article__body entry-content">
<?php
the_content(
sprintf(
wp_kses(
/* translators: %s: Post title */
__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'viitorx' ),
array(
'span' => array(
'class' => array(),
),
)
),
wp_kses_post( get_the_title() )
)
);
wp_link_pages(
array(
'before' => '<nav class="page-links" aria-label="' . esc_attr__( 'Post pages', 'viitorx' ) . '"><span class="page-links-title">' . esc_html__( 'Pages:', 'viitorx' ) . '</span>',
'after' => '</nav>',
)
);
?>
</div>
</div>
<aside class="blog-sidebar" aria-label="<?php esc_attr_e( 'Sidebar', 'viitorx' ); ?>">
<section class="panel panel--toc" aria-label="<?php esc_attr_e( 'Table of contents', 'viitorx' ); ?>">
<h2 class="panel__kicker"><?php esc_html_e( 'Table of Contents', 'viitorx' ); ?></h2>
<p class="toc__empty" id="blog-toc-empty" hidden><?php esc_html_e( 'Section headings will appear here when this article uses subheadings.', 'viitorx' ); ?></p>
<nav class="toc" id="blog-single-toc" aria-label="<?php esc_attr_e( 'On this page navigation', 'viitorx' ); ?>"></nav>
</section>
<section class="panel panel--cta" aria-label="<?php esc_attr_e( 'Sidebar call to action', 'viitorx' ); ?>">
<p class="panel__headline"><?php esc_html_e( 'Future in mind? We turn it into reality.', 'viitorx' ); ?></p>
<a class="btn btn--primary btn--sm" href="<?php echo esc_url( $contact_url ); ?>"><?php esc_html_e( 'Let’s Talk', 'viitorx' ); ?></a>
</section>
<section class="panel panel--share" aria-label="<?php esc_attr_e( 'Share', 'viitorx' ); ?>">
<h2 class="panel__kicker"><?php esc_html_e( 'Share', 'viitorx' ); ?></h2>
<ul class="share" aria-label="<?php esc_attr_e( 'Share links', 'viitorx' ); ?>">
<li class="share__item">
<a class="share__icon" href="<?php echo esc_url( $viitorx_share_facebook ); ?>" target="_blank" rel="noopener noreferrer" aria-label="<?php esc_attr_e( 'Share on Facebook', 'viitorx' ); ?>">
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="#ffffff" aria-hidden="true"><path d="M24 12.073C24 5.405 18.627 0 12 0S0 5.405 0 12.073C0 18.1 4.388 23.094 10.125 24v-8.437H7.078v-3.49h3.047V9.41c0-3.025 1.791-4.697 4.533-4.697 1.313 0 2.686.236 2.686.236v2.97h-1.514c-1.491 0-1.956.93-1.956 1.884v2.25h3.328l-.532 3.49h-2.796V24C19.612 23.094 24 18.1 24 12.073z"/></svg>
</a>
</li>
<li class="share__item">
<a class="share__icon" href="<?php echo esc_url( $viitorx_share_x ); ?>" target="_blank" rel="noopener noreferrer" aria-label="<?php esc_attr_e( 'Share on X', 'viitorx' ); ?>">
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="#ffffff" aria-hidden="true"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.744l7.737-8.835L1.254 2.25H8.08l4.253 5.622zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>
</a>
</li>
<li class="share__item">
<a class="share__icon" href="<?php echo esc_url( $viitorx_share_linkedin ); ?>" target="_blank" rel="noopener noreferrer" aria-label="<?php esc_attr_e( 'Share on LinkedIn', 'viitorx' ); ?>">
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="#ffffff" aria-hidden="true"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 0 1-2.063-2.065 2.064 2.064 0 1 1 2.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg>
</a>
</li>
<li class="share__item">
<a class="share__icon" href="<?php echo esc_url( $viitorx_share_pinterest ); ?>" target="_blank" rel="noopener noreferrer" aria-label="<?php esc_attr_e( 'Share on Pinterest', 'viitorx' ); ?>">
<span class="share__icon-svg" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="#ffffff"><path d="M12.017 0C5.396 0 .029 5.367.029 11.987c0 5.079 3.158 9.417 7.618 11.162-.105-.949-.199-2.403.041-3.439.219-.937 1.406-5.957 1.406-5.957s-.359-.72-.359-1.781c0-1.663.967-2.911 2.168-2.911 1.024 0 1.518.769 1.518 1.688 0 1.029-.653 2.567-.992 3.992-.285 1.193.6 2.165 1.775 2.165 2.128 0 3.768-2.245 3.768-5.487 0-2.861-2.063-4.869-5.008-4.869-3.41 0-5.409 2.562-5.409 5.199 0 1.033.394 2.143.889 2.741.099.12.112.225.085.345-.09.375-.293 1.199-.334 1.363-.053.225-.172.271-.401.165-1.495-.69-2.433-2.878-2.433-4.646 0-3.776 2.748-7.252 7.92-7.252 4.158 0 7.392 2.967 7.392 6.923 0 4.135-2.607 7.462-6.233 7.462-1.214 0-2.354-.629-2.758-1.379l-.749 2.848c-.269 1.045-1.004 2.352-1.498 3.146 1.123.345 2.306.535 3.55.535 6.607 0 11.985-5.365 11.985-11.987C23.97 5.39 18.592 0 11.985 0z"/></svg></span>
</a>
</li>
<li class="share__item">
<button type="button" class="share__icon share__icon--copy" data-share="copy" aria-label="<?php esc_attr_e( 'Copy post URL', 'viitorx' ); ?>">
<span class="share__icon-svg share__icon-svg--link" aria-hidden="true">
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="#ffffff" stroke-width="1.85" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>
</span>
</button>
</li>
</ul>
</section>
</aside>
</div>
</section>
<?php if ( $related->have_posts() ) : ?>
<section class="related" aria-label="<?php esc_attr_e( 'Related insights', 'viitorx' ); ?>" data-section-reveal>
<div class="container related__inner">
<h2 class="related__title"><?php esc_html_e( 'Related Insights', 'viitorx' ); ?></h2>
<div class="related-grid">
<?php
while ( $related->have_posts() ) :
$related->the_post();
$r_thumb = get_the_post_thumbnail_url( get_the_ID(), 'large' );
?>
<a class="related-card" href="<?php the_permalink(); ?>">
<?php if ( $r_thumb ) : ?>
<span class="related-card__img-wrap">
<img class="related-card__img" src="<?php echo esc_url( $r_thumb ); ?>" alt="" loading="lazy" decoding="async" width="514" height="400">
</span>
<?php endif; ?>
<h3 class="related-card__title"><?php the_title(); ?></h3>
</a>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
</div>
<a class="btn btn--primary btn--ghost" href="<?php echo esc_url( $blog_list_url ); ?>"><?php esc_html_e( 'View All', 'viitorx' ); ?></a>
</div>
</section>
<?php endif; ?>
</article>
</div>