The situation is this: I have created a custom post type which works perfectly, now I want to create a specific archive page template for the taxonomies of this post type.
I duplicated the archive.php
page of my theme (schema by MTS) but it doesn’t work in this case.
Here the code:
<?php
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ), get_query_var( 'count' ) );
echo $term->name;
echo ' has nr elements: ';
echo $term->count;
?>
<div id="page">
<div class="<?php mts_article_class(); ?>">
<div id="content_box">
<h1 class="postsby">
<span><?php echo the_archive_title(); ?></span>
</h1>
<?php $j = 0; if (have_posts()) : while (have_posts()) : the_post(); ?>
<article class="latestPost excerpt <?php echo (++$j % 3 == 0) ? 'last' : ''; ?>">
<?php mts_archive_post(); ?>
</article><!--.post excerpt-->
<?php endwhile; else: echo 'nothing'; endif; ?>
<?php if ( $j !== 0 ) { // No pagination if there is no posts ?>
<?php mts_pagination(); ?>
<?php } ?>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
The strange aspect is that the code print “nothing” because the function have_posts()
return false but the $term->count
is 3
.
Can you help me please? Thank you very much in advance!