File: /home/carrerup/.trash/techland/inc/template-parts/post-formats.php
<?php
/*************************************************
## FORMATS_CONTENT
*************************************************/
if (! function_exists('techland_post')) {
function techland_post()
{
//add sticky class to post if post sticked
$sticky = (is_sticky()) ? ' -has-sticky ' : '';
$readmore = techland_settings('post_button_title', 'Read More');
$excerptsz = techland_settings('excerptsz', '10');
ob_start();
post_class(esc_attr('nt-blog-item col-12 col-sm-12 d-sm-flex'.$sticky));
echo'<div id="post-'.get_the_ID().'" '.ob_get_clean().' >
<div class="nt-blog-item-inner">';
techland_post_format();
//post content wrapper div
echo '<div class="nt-blog-info">';
techland_post_categories();
// post title
if ('0' != techland_settings('post_title_visibility', '1')) {
the_title(sprintf('<h4 class="nt-blog-info-title __title"><a href="%s" rel="bookmark">', esc_url(get_permalink())), '</a></h3>');
}
// post meta function contains author - date - comments
if (!is_search()) {
techland_post_meta();
}
// post content function for loop excerpt.
if ('0' != techland_settings('post_excerpt_visibility', '1') && has_excerpt()) {
echo '<div class="nt-blog-info-excerpt">'. wp_trim_words(get_the_excerpt(), $excerptsz) .'</div>';
}
if (!is_search()) {
// post read-more button.
if ('0' != techland_settings('post_button_visibility', '1')) {
echo '<div class="nt-blog-info-link">
<a href="'.esc_url(get_permalink()).'" class="nt-btn-theme nt-post-button custom-btn custom-btn--medium custom-btn--style-2">'.esc_html($readmore).'</a>
</div>';
}
}
// this function must be using for wp linkable pages, don't delete!
techland_wp_link_pages();
// end post content wrapper div
echo '</div>
</div>
</div>';
}
}
if (! function_exists('techland_post_style_one')) {
function techland_post_style_one()
{
$out = '';
//add sticky class to post if post sticked
$sticky = (is_sticky()) ? ' -has-sticky ' : '';
$col = techland_settings('grid_column', '6');
$readmore = techland_settings('post_button_title', 'Read More');
$excerptsz = techland_settings('excerptsz', '16');
$alignment = techland_settings('post_alignment');
$use_as_bg = get_post_meta(get_the_ID(), 'techland_post_use_bg', true);
$postbg = wp_get_attachment_url( get_post_thumbnail_id(),'full' );
$use_as_bg = $use_as_bg == true ? ' style="background-image: url('.$postbg.');"' : '';
$bodyclass = $use_as_bg == true ? ' d-sm-flex align-items-sm-end' : '';
$colorclass = $use_as_bg == true ? ' text-white' : '';
ob_start();
post_class(esc_attr('col-12 col-sm-6 col-lg-'.$col.' d-sm-flex '.$alignment.$sticky));
$out .= '<div id="post-'.get_the_ID().'" '.ob_get_clean().' >';
$out .= '<div class="__item __item--preview __item--rounded __item--shadow"'.$use_as_bg.'>';
if (has_post_thumbnail() && $use_as_bg != true) {
ob_start();
the_post_thumbnail( 'full', array( 'class' => 'img-fluid' ) );
$out .= '<div class="__header"><a href="'.get_permalink().'" title="'.the_title_attribute( 'echo=0' ).'"><figure class="__image __image--rounded">'.ob_get_clean().'</figure></a></div>';
}
$out .= '<div class="__body'.$bodyclass.'">';
$out .= '<div class="__content">';
$out .= '<div class="post-meta'.$colorclass.'">';
$out .= '<div class="row justify-content-between align-items-center">';
// post author
if ( '0' != techland_settings('post_author_visibility', '1')) {
$out .= '<div class="col-auto">';
$out .= '<span class="post-meta__item __author">by '.get_the_author().'</span>';
$out .= '</div>';
}
// post date
if ( '0' != techland_settings('post_date_visibility', '1')) {
$out .= '<div class="col-auto">';
$out .= '<span class="post-meta__item __date-post">'.get_the_date('j D').'</span>';
$out .= '</div>';
}
$out .= '</div>';
$out .= '</div>';
// post title
if ( '0' != techland_settings('post_title_visibility', '1')) {
$out .= '<h4 class="__title'.$colorclass.'"><a href="'.get_permalink().'" title="'.the_title_attribute( 'echo=0' ).'">'.get_the_title().'</a></h4>';
}
// post excerpt
if ('0' != techland_settings('post_excerpt_visibility', '1') && has_excerpt() ) {
$out .='<p>' . wp_trim_words(get_the_excerpt(), $excerptsz) . '</p>';
}
$out .= '</div>';
$out .= '</div>';
// post category
if ('0' != techland_settings('post_category_visibility', '1') && has_category()) {
$out .= '<div class="__footer">';
$out .= '<div class="tags-list">';
$out .= '<ul>';
$categories = get_the_category();
foreach ($categories as $cat) {
$out .= '<li>
<a href="'.esc_url( get_category_link( $cat->term_id ) ).'">'.esc_html( $cat->name ).'</a>
</li>';
}
$out .= '</ul>';
$out .= '</div>';
$out .= '</div>';
}
ob_start();
techland_wp_link_pages();
$out .= ob_get_clean();
$out .= '</div>';
$out .= '</div>';
return $out;
}
}
if (! function_exists('techland_post_style_two')) {
function techland_post_style_two()
{
$out = '';
//add sticky class to post if post sticked
$sticky = (is_sticky()) ? ' -has-sticky ' : '';
$col = techland_settings('grid_column', '6');
$readmore = techland_settings('post_button_title', 'Read More');
$excerptsz = techland_settings('excerptsz', '16');
$alignment = techland_settings('post_alignment');
ob_start();
post_class(esc_attr('col-12 col-sm-6 col-lg-'.$col.' d-sm-flex '.$alignment.$sticky));
$out .= '<div id="post-'.get_the_ID().'" '.ob_get_clean().' >';
$out .= '<div class="__item __item--preview">';
$out .= '<div class="__header">';
$out .= '<span class="__date-post"><strong>'.get_the_date('j').'</strong>'.get_the_date('D').'</span>';
if (has_post_thumbnail()) {
ob_start();
the_post_thumbnail( 'full', array( 'class' => '' ) );
$out .= '<figure class="__image">'.ob_get_clean().'</figure>';
}
$out .= '</div>';
$out .= '<div class="__body">';
$out .= '<div class="__content">';
if ('0' != techland_settings('post_category_visibility', '1') && has_category()) {
$categories = get_the_category();
$out .= '<div class="post-meta">';
$out .= '<span class="post-meta__item">'.esc_html(strtoupper($categories[0]->name )).'</span>';
$out .= '</div>';
}
// post title
if ( '0' != techland_settings('post_title_visibility', '1')) {
$out .= '<h4 class="__title"><a href="'.get_permalink().'" title="'.the_title_attribute( 'echo=0' ).'">'.get_the_title().'</a></h4>';
}
// post excerpt
if ('0' != techland_settings('post_excerpt_visibility', '1') && has_excerpt()) {
$out .= wp_trim_words(get_the_excerpt(), $excerptsz);
}
// post button
if ('0' != techland_settings('post_button_visibility', '1')) {
$out .= '<p><a class="__more-link" href="'.get_permalink().'" title="'.the_title_attribute( 'echo=0' ).'">'.esc_html($readmore).'</a></p>';
}
ob_start();
techland_wp_link_pages();
$out .= ob_get_clean();
$out .= '</div>';
$out .= '</div>';
$out .= '</div>';
$out .= '</div>';
return $out;
}
}
if (! function_exists('techland_post_style_three')) {
function techland_post_style_three()
{
$out = '';
//add sticky class to post if post sticked
$sticky = (is_sticky()) ? ' -has-sticky ' : '';
$col = techland_settings('grid_column', '6');
$excerptsz = techland_settings('excerptsz', '16');
$alignment = techland_settings('post_alignment');
if (has_post_thumbnail()) {
ob_start();
post_class(esc_attr('col-12 col-sm-6 col-lg-'.$col.' d-sm-flex '.$alignment.$sticky));
$out .= '<div id="post-'.get_the_ID().'" '.ob_get_clean().'>';
$out .= '<div class="__item __item--preview __item--rounded __item--shadow">';
ob_start();
the_post_thumbnail( 'full', array( 'class' => '' ) );
$out .= '<div class="__header"><figure class="__image"><a href="'.get_permalink().'">'.ob_get_clean().'</a></figure></div>';
$out .= '<div class="__body">';
$out .= '<div class="__content">';
// post date
if ( '0' != techland_settings('post_date_visibility', '1')) {
$out .= '<div class="post-meta">';
$out .= '<span class="post-meta__item __date-post">'.get_the_date('j D').'</span>';
$out .= '</div>';
}
// post title
if ( '0' != techland_settings('post_title_visibility', '1')) {
$out .= '<h4 class="__title"><a href="'.get_permalink().'" title="'.the_title_attribute( 'echo=0' ).'">'.get_the_title().'</a></h4>';
}
$out .= '</div>';
$out .= '</div>';
$out .= '</div>';
$out .= '</div>';
}
return $out;
}
}
if (! function_exists('techland_post_style_four')) {
function techland_post_style_four()
{
$out = '';
//add sticky class to post if post sticked
$sticky = (is_sticky()) ? ' -has-sticky ' : '';
$col = techland_settings('grid_column', '6');
$readmore = techland_settings('post_button_title', 'Read More');
$excerptsz = techland_settings('excerptsz', '16');
$alignment = techland_settings('post_alignment');
ob_start();
post_class(esc_attr('col-12 col-md-'.$col.' d-md-flex '.$alignment.$sticky));
$out .= '<div id="post-'.get_the_ID().'" '.ob_get_clean().' >';
$out .= '<div class="__item __item--preview __item--rounded __item--shadow">';
$out .= '<div class="__body">';
$out .= '<div class="__content">';
$out .= '<div class="post-meta">';
$out .= '<span class="post-meta__item __date-post">'.get_the_date('j F').'’ '.get_the_date('y').'</span>';
$out .= '</div>';
// post title
if ( '0' != techland_settings('post_title_visibility', '1')) {
$out .= '<h4 class="__title"><a href="'.get_permalink().'" title="'.the_title_attribute( 'echo=0' ).'">'.get_the_title().'</a></h4>';
}
// post excerpt
if ('0' != techland_settings('post_excerpt_visibility', '1') && has_excerpt()) {
$out .= wp_trim_words(get_the_excerpt(), $excerptsz);
}
$out .= '</div>';
$out .= '</div>';
if ('0' != techland_settings('post_button_visibility', '1')) {
$out .= '<div class="__footer">';
$out .= '<div class="mt-4">';
$out .= '<a class="custom-btn custom-btn--medium custom-btn--style-2" href="'.get_permalink().'" title="'.the_title_attribute( 'echo=0' ).'"> '.esc_html($readmore).' </a>';
$out .= '</div>';
$out .= '</div>';
}
$out .= '</div>';
$out .= '</div>';
return $out;
}
}
/*************************************************
## POST FORMAT
*************************************************/
if (! function_exists('techland_post_format')) {
function techland_post_format()
{
// post format
$format = get_post_format();
$format = $format ? $format : 'standard';
// post format video or audio embed
if ('video' == $format || 'audio' == $format) {
$content = rwmb_meta('techland_embed_content');
// Only get video from the content if a playlist isn't present.
if (false === strpos($content, 'wp-playlist-script')) {
$embed = get_media_embedded_in_content($content, array( 'video', 'object', 'embed', 'iframe', 'audio' ));
}
// If not a single post, highlight the video file.
if (! empty($embed)) {
foreach ($embed as $embed_html) {
echo '<div class="nt-blog-media embed-responsive embed-responsive-16by9 fitvids">'. wp_kses($embed_html, techland_allowed_html()) .'</div>';
}
}
// post format gallery
} elseif ('gallery' == $format) {
$images = rwmb_meta('techland_post_gallery', array( 'size' => 'full', 'type' => 'image_advanced' ));
if ($images) {
wp_enqueue_style('owl-carousel');
wp_enqueue_script('owl-carousel');
echo '<div class="nt-post-gallery-type owl-carousel -js-carousel">';
foreach ($images as $image) {
echo '<div class="nt-blog-media post-gallery-item">
<a href="'.esc_url(get_permalink()).'">
<img src="'.esc_url($image['full_url']).'" alt="'.esc_attr($image['alt']).'">
</a>
</div>';
}
echo '</div>';
}
// standart post
} else {
if (has_post_thumbnail()) {
$thumbnail = get_the_post_thumbnail_url(get_the_ID(), 'techland-820-hard');
echo '<div class="nt-blog-media">
<a class="nt-blog-media-link" href="'.esc_url(get_permalink()).'">';
the_post_thumbnail( 'full', array( 'class' => 'img-fluid' ) );
echo'</a>
</div>';
}
} // end post format
}
}
/*************************************************
## POST/CPT META
*************************************************/
if (! function_exists('techland_post_meta')) {
function techland_post_meta()
{
global $post;
$archive_year = get_the_time('Y');
$archive_month = get_the_time('m');
$archive_day = get_the_time('d');
$author_id = get_the_author_meta('ID');
$author_link = get_author_posts_url($author_id);
if ('0' != techland_settings('post_meta_visibility', '1')) {
?>
<!-- Post Category, Author, Comments -->
<ul class="nt-blog-info-meta">
<?php
if (is_sticky()) {
echo '<div class="nt-sticky-label">'.esc_html__('Sticky', 'techland').'</div>';
}
// post author
if ('0' != techland_settings('post_author_visibility', '1')) {
?>
<li class="nt-blog-info-meta-item">
<a class="nt-blog-info-meta-link" href="<?php echo esc_url($author_link); ?>"><?php the_author(); ?></a>
</li>
<?php
}
if( 'masonry' != techland_settings( 'index_type', 'default' ) ) {
// post comments
if ('0' != techland_settings('post_comments_visibility', '1')) {
?>
<li class="nt-blog-info-meta-item">
<a class="nt-blog-info-meta-link" href="<?php echo get_comments_link( $post->ID ); ?>"><?php comments_number(); ?></a>
</li>
<?php
}
}
// post date
if ('0' != techland_settings('post_date_visibility', '1')) {
?>
<li class="nt-blog-info-meta-item">
<a class="nt-blog-info-meta-link" href="<?php echo esc_url(get_day_link($archive_year, $archive_month, $archive_day)); ?>">
<?php the_time(get_option('date_format')); ?>
</a>
</li>
<?php
}
?>
</ul>
<?php
}
}
}
/*************************************************
## SINLGE POST/CPT TAGS
*************************************************/
if (! function_exists('techland_post_categories')) {
function techland_post_categories()
{
if ('0' != techland_settings('post_category_visibility', '1') && has_category()) {
?>
<!-- Post Categories -->
<h5 class="nt-blog-info-category"><?php the_category(', '); ?></h5>
<?php
}
}
add_action( 'techland_post_categories_action', 'techland_post_categories', 10 );
}
/*************************************************
## POST/CPT DATE
*************************************************/
if (! function_exists('techland_post_date')) {
function techland_post_date()
{
$archive_year = get_the_time('Y');
$archive_month = get_the_time('m');
$archive_day = get_the_time('d');
?>
<li class="nt-blog-info-meta-item">
<a class="nt-blog-info-meta-link post-date" href="<?php echo esc_url(get_day_link($archive_year, $archive_month, $archive_day)); ?>">
<i class="fa fa-calendar"></i>
<?php the_time(get_option('date_format')); ?>
</a>
</li>
<?php
}
add_action( 'techland_post_date_action', 'techland_post_date', 10 );
}
/*************************************************
## POST/CPT AUTHOR
*************************************************/
if (! function_exists('techland_post_author')) {
function techland_post_author()
{
?>
<li class="nt-blog-info-meta-item">
<a class="nt-blog-info-meta-link post-author" href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?>">
<i class="fa fa-user"></i>
<?php the_author(); ?>
</a>
</li>
<?php
}
add_action( 'techland_post_author_action', 'techland_post_author', 10 );
}
/*************************************************
## POST/CPT COMMENT
*************************************************/
if (! function_exists('techland_post_comment')) {
function techland_post_comment()
{
?>
<li class="nt-blog-info-meta-item">
<a class="nt-blog-info-meta-link post-comment" href="<?php echo get_comments_link( get_the_ID() ); ?>">
<i class="fa fa-comments"></i>
<?php comments_number(); ?>
</a>
</li>
<?php
}
add_action( 'techland_post_comment_action', 'techland_post_comment', 10 );
}
/*************************************************
## SINLGE POST/CPT TAGS
*************************************************/
if (! function_exists('techland_single_post_tags')) {
function techland_single_post_tags()
{
if ('0' != techland_settings('single_postmeta_tags_visibility', '1')) {
if (has_tag()) {
?>
<!-- Post Tags -->
<div class="nt-post-tags">
<ul class="nt-tags-list">
<?php
$tags = get_the_tags(get_the_ID());
foreach ($tags as $tag) {
echo '<li class="nt-tags-list-item">
<a class="nt-tags-list-link uppercase '. esc_attr($tag->name) .'" href="'.esc_url(get_tag_link($tag->term_id)).'">'. esc_html($tag->name) .'</a>
</li>';
}
?>
</ul>
</div>
<!-- Post Tags End -->
<?php
}
}
}
}
/*************************************************
## SINLGE POST/CPT TAGS 2
*************************************************/
if (! function_exists('techland_single_post_tags_two')) {
function techland_single_post_tags_two()
{
if ('0' != techland_settings('single_postmeta_tags_visibility', '1')) {
if (has_tag()) {
?>
<div class="h5"><?php esc_html_e('Tags:', 'techland'); ?></div>
<div class="tags-list">
<ul class="">
<?php
$colors = array('695afd','f94a11','0cbc5a','feb302','34c7df','df2727','eec41a','e93053');
$tags = get_the_tags(get_the_ID());
$count = 0;
foreach ($tags as $tag) {
$cat_clr = $colors[$count];
$rgb = techland_hex2rgb($colors[$count]);
$rgb = implode(", ", $rgb);
echo '<li><a class="'. esc_attr($tag->name) .'" href="'.esc_url(get_tag_link($tag->term_id)).'" style="background:rgba('.$rgb.',0.1);color:#'.$cat_clr.';">'. esc_html($tag->name) .'</a></li>';
$count++;
}
?>
</ul>
</div>
<?php
}
}
}
}
/*************************************************
## SINGLE POST AUTHOR BOX FUNCTION
*************************************************/
if (! function_exists('techland_single_post_author_box')) {
function techland_single_post_author_box()
{
global $post;
if ('0' != techland_settings('single_post_author_box_visibility', '1')) {
// Get author's display name
$display_name = get_the_author_meta('display_name', $post->post_author);
// If display name is not available then use nickname as display name
$display_name = empty($display_name) ? get_the_author_meta('nickname', $post->post_author) : $display_name ;
// Get author's biographical information or description
$user_description = get_the_author_meta('user_description', $post->post_author);
// Get author's website URL
$user_website = get_the_author_meta('url', $post->post_author);
// Get link to the author archive page
$user_posts = get_author_posts_url(get_the_author_meta('ID', $post->post_author));
// Get the rest of the author links. These are stored in the
// wp_usermeta table by the key assigned in wpse_user_contactmethods()
$author_facebook = get_the_author_meta('facebook', $post->post_author);
$author_twitter = get_the_author_meta('twitter', $post->post_author);
$author_linkedin = get_the_author_meta('linkedin', $post->post_author);
$author_youtube = get_the_author_meta('youtube', $post->post_author);
if ('' != $user_description) {
?>
<div class="container-author-box">
<h3 class="nt-inner-title"><?php echo esc_html_e('About The Author', 'techland'); ?></h3>
<div class="row">
<div class="col-md-2">
<a href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?>">
<?php if (function_exists('get_avatar')) {
echo get_avatar(get_the_author_meta('email'), '100');
} ?>
</a>
</div>
<div class="col-md-10">
<h5 class="nt-single-post-related-time"><a class="u-color-dark u-text-capitalize" href="<?php echo esc_url($user_posts); ?>"><?php echo esc_html($display_name); ?></a></h5>
<p><?php echo esc_html($user_description); ?></p>
<div class="nt-author-social -color-mixed-default -hover-mixed-outline -corner-circle -size-medium">
<ul class="nt-author-social-inner">
<?php if ('' != $author_facebook) { ?>
<li class="nt-author-social-item"><a class="nt-author-social-link -icon-facebook" href="<?php echo esc_url($author_facebook); ?>" target="_blank"><i class="fa fa-facebook" aria-hidden="true"></i></a></li>
<?php } ?>
<?php if ('' != $author_twitter) { ?>
<li class="nt-author-social-item"><a class="nt-author-social-link -icon-twitter" href="<?php echo esc_url($author_twitter); ?>" target="_blank"><i class="fa fa-twitter" aria-hidden="true"></i></a></li>
<?php } ?>
<?php if ('' != $author_linkedin) { ?>
<li class="nt-author-social-item"><a class="nt-author-social-link -icon-linkedin" href="<?php echo esc_url($author_linkedin); ?>" target="_blank"><i class="fa fa-linkedin" aria-hidden="true"></i></a></li>
<?php } ?>
<?php if ('' != $author_youtube) { ?>
<li class="nt-author-social-item"><a class="nt-author-social-link -icon-youtube" href="<?php echo esc_url($author_youtube); ?>" target="_blank"><i class="fa fa-youtube" aria-hidden="true"></i></a></li>
<?php } ?>
</ul>
</div>
</div>
</div>
</div>
<?php
}
}
}
}
/*************************************************
## SINGLE PAGE POST CONTENT FUNCTION
*************************************************/
if (! function_exists('techland_single_page_post_content')) {
function techland_single_page_post_content()
{
$margin = 'mt-0 mb-lg-4';
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'large', array('class' => 'img-fluid') );
$margin = 'mt-6 mt-lg-10 mb-lg-4';
}
if ('0' != techland_settings('single_post_author_visibility', '1') ) {
?>
<div class="<?php echo esc_attr( $margin ); ?>">
<div class="row align-items-sm-center justify-content-sm-between">
<div class="col-12 col-sm-auto mb-4">
<div class="post-author">
<div class="d-table">
<div class="d-table-cell align-middle">
<div class="post-author__img">
<a href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?>">
<?php if (function_exists('get_avatar')) {
echo get_avatar(get_the_author_meta('email'), '70');
} ?>
</a>
</div>
</div>
<div class="d-table-cell align-middle">
<span class="post-author__name"><?php the_author(); ?></span>
<span class="post-single__date"> <?php the_time(get_option('date_format')); ?></span>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
}
?>
<h3><?php the_title(); ?></h3>
<?php
the_content();
techland_wp_link_pages();
if ( has_category() && '0' != techland_settings('single_post_category_visibility', '1') ) {
?>
<div class="my-6 my-md-11">
<div class="h5"><?php esc_html_e('Categories:', 'techland'); ?></div>
<div class="cats-list">
<ul class="nt-post-category-links">
<?php
$categories = get_the_category();
foreach( $categories as $category ) { ?>
<li>
<a href="<?php echo esc_url( get_category_link( $category->term_id ) );?>">
<?php echo esc_html( $category->name );?>
</a>
</li>
<?php
}
?>
</ul>
</div>
<?php techland_single_post_tags_two(); ?>
</div>
<?php
}
}
}
/*************************************************
## SINGLE POST RELATED POSTS
*************************************************/
if (! function_exists('techland_single_post_related')) {
function techland_single_post_related()
{
if ( '0' != techland_settings('single_related_visibility', '1') ) {
global $post;
$tags = wp_get_post_tags($post->ID);
if ( $tags ) {
?>
<div class="nt-single-post-related">
<h3 class="nt-inner-title"><?php echo esc_html_e('You Might Also Like', 'techland'); ?></h3>
<div class="row">
<?php
$tag_ids = array();
foreach ($tags as $individual_tag) {
$tag_ids[] = $individual_tag->term_id;
}
$args = array(
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'posts_per_page'=>3,
);
$like_query = new wp_query($args);
while ($like_query->have_posts()) {
$like_query->the_post();
?>
<div class="col-md-4 col-sm-4">
<div class="nt-single-post-related-item">
<?php if (has_post_thumbnail()) { ?>
<div class="nt-single-post-related-image">
<a href="<?php esc_url( the_permalink() ); ?>"><?php the_post_thumbnail(array(200,200)); ?></a>
</div>
<?php } ?>
<h5 class="nt-single-post-related-title"><a class="u-color-dark" href="<?php esc_url( the_permalink() ); ?>"><?php the_title(); ?></a></h5>
<h6 class="nt-single-post-related-time"><?php the_time('F j, Y'); ?></h6>
</div>
</div>
<?php
}
wp_reset_postdata();
?>
</div>
</div>
<?php
}
}
}
}
/*************************************************
## SINGLE POST RELATED POSTS 2
*************************************************/
if (! function_exists('techland_single_post_related_two')) {
function techland_single_post_related_two()
{
if ('0' != techland_settings('single_related_visibility', '1')) {
global $post;
$cats = get_the_category($post->ID);
$first_cat = $cats[0]->term_id;
$args = array(
'category__in' => array($first_cat),
'post__not_in' => array($post->ID),
'posts_per_page'=>3,
);
// Query posts
$related_cats_post = new WP_Query( $args );
$colors = array('695afd','f94a11','0cbc5a','feb302','34c7df','df2727','eec41a','e93053');
if ( $related_cats_post->have_posts() ) {
?>
<div class="py-3 py-md-6 py-lg-12">
<h3 class="mb-6"><?php echo techland_settings('related_title', 'Related Article'); ?></h3>
<!-- start posts -->
<div class="posts posts--s1">
<div class="__inner">
<div class="row">
<?php
while( $related_cats_post->have_posts()) {
$related_cats_post->the_post();
?>
<div class="col-12 col-sm-6 col-lg-6 col-xl-4 d-sm-flex">
<div class="__item __item--preview __item--rounded __item--shadow">
<div class="__header">
<?php if ( has_post_thumbnail() ) : ?>
<figure class="__image __image--rounded">
<a href="<?php esc_url( the_permalink() ); ?>"><?php the_post_thumbnail(); ?></a>
</figure>
<?php endif; ?>
</div>
<div class="__body">
<div class="__content">
<div class="post-meta">
<div class="row justify-content-between align-items-center">
<div class="col-auto">
<span class="post-meta__item __author">
<?php echo esc_html_e('by', 'techland'); ?> <?php the_author(); ?>
</span>
</div>
<div class="col-auto">
<span class="post-meta__item __date-post"><?php the_time('j D'); ?></span>
</div>
</div>
</div>
<h4 class="__title"><a href="<?php esc_url( the_permalink() ); ?>"><?php echo get_the_title(); ?> </a></h4>
<?php if ( ! has_post_thumbnail()) : ?>
<p><?php echo wp_trim_words(get_the_excerpt(), 25); ?></p>
<?php endif; ?>
</div>
</div>
<?php if (has_category()) : ?>
<div class="__footer">
<div class="tags-list">
<ul>
<?php
$categories = get_the_category();
foreach ($categories as $cat) {
?>
<li><a href="<?php echo esc_url( get_category_link( $cat->term_id ) );?>"><?php echo esc_html( $cat->name );?></a></li>
<?php
}
?>
</ul>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?php
}
wp_reset_postdata();
?>
</div>
</div>
</div>
<!-- end posts -->
</div>
<?php
}
}
}
}