custom taxonomy – Why my archive title isn’t showing?

Question

I’ve a strange problem (well, maybe stupid, but I’m too burned out). My archive pages show the title ONLY IF THEY DON’T HAVE POSTS. However, when there are posts, the title shows up without a problem. Furthermore, this only happens in the archives for a custom taxonomy. The archives for categories, tags and authors work fine.

I’m sure it’s something stupid, but right now I just need some fresh eyes to check it out. Here’ is my code:

<div class="container">


    <div class="pageTitle row">
        
    <?php if (have_posts()) : ?>
        <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
        <?php /* If this is a category archive */ if (is_category()) { ?>
        <div class="posttitle">
            <h1>
                <?php single_cat_title(); ?>
            </h1>
        </div>
        <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
        <div class="posttitle">
            <h1>Entradas con palabra clave <span class="producertitle"><?php single_cat_title(); ?></span></h1>
        </div>
        <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
        <div class="posttitle">
            <h1>Entradas con fecha
                <?php the_time('F jS, Y'); ?>
            </h1>
        </div>
        <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
        <div class="posttitle">
            <h1>Entradas del mes
                <?php the_time('F, Y'); ?>
            </h1>
        </div>
        <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
        <div class="posttitle">
            <h1>Entradas del año
                <?php the_time('Y'); ?>
            </h1>
        </div>
        <?php /* If this is an author archive */ } elseif (is_author()) { ?>
        <div class="posttitle">
            <h1>Artículos por <?php the_author(); ?></h1>
        </div>


        <?php
            if ( is_post_type_archive() ) {
        ?>
        <h1>
            <?php post_type_archive_title(); ?>
        </h1>
        <?php
        }
        ?>
        <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
        <div class="posttitle">
            <h1>Archivo de Entradas</h1>
        </div>
        <?php } ?>
        
    </div>

0
devin 3 weeks 2023-03-08T17:10:39-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse