вывожу записи custom type (blog) в tag.php
<div class="stati-wrp">
<?php
// global $post;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$related_tax = 'post_tag';
$tax_id = get_queried_object()->term_id;
$tax_slug = get_queried_object()->slug;
//$cats_tags_or_taxes = wp_get_object_terms($post->ID, $related_tax, array('fields' => 'ids'));
$args = array(
'post_type' => 'blog',
'posts_per_page' => 2,
'paged' => $paged,
'tax_query' => array(
array(
'taxonomy' => $related_tax,
'field' => 'slug',
'terms' => $tax_slug,
)
)
);
$my_query = new WP_Query($args);
if ($my_query->have_posts()) { ?>
<?php
while ($my_query->have_posts()) : $my_query->the_post();
?>
<div class="stati-item">
<a class="stati-item-link" href="<?= get_the_permalink(); ?>"></a>
<div class="stati-item-hren">
<img alt="" src="<?= get_template_directory_uri(); ?>/assets/img/share-icon.png">
</div>
<div class="stati-item-photo" style="background: url(<?= $main_first_thumb_url[0]; ?>); background-repeat: no-repeat; background-size: cover; background-position: center;"></div>
<div class="stati-item-info">
<div class="stati-item-name">
<?php the_title(); ?>
</div>
<div class="stati-item-data">
<?= get_the_date('d.m.Y'); ?>
</div>
<div class="stati-item-profil">
<div class="stati-item-profil-foto" style="background: url(<?= $author_image; ?>); background-repeat: no-repeat; background-size: cover; background-position: center;"></div>
<div class="stati-item-profil-info">
<div class="stati-item-profil-name"><?= $author[0]->name;; ?></div>
<div class="stati-item-profil-tag"><?= $author_tags; ?></div>
</div>
</div>
<div class="stati-item-text"><?= get_the_excerpt(); ?></div>
</div>
</div>
<?php endwhile;
} else {
echo '<h2>Извините, ничего не найдено...</h2>'; ?>
<?php
}
?>
<?php wp_reset_postdata(); ?>
</div>
<div class="stati-pagination">
<div class="pagination-numbers"><?php wp_pagenavi(array('query' => $my_query)); ?></div>
</div>