0

I have a fairly standard "if" construct to detect what archive.php should display (see below)

I also have a custom post type and a custom category. When a user clicks a displayed category (taxonomy) term in my postmeta, it loads archive.php and goes all the way to the "else" case, and displays the matching "Design Pattern" taxonomy term that was clicked. Fine.

However, the same is not true for tags. If a user clicks on a Tag in the postmeta, archive.php loads with its "nothing found" displayed, with this URL:

mysite.com/wordpress/tag/action-button/

I would expect the code below to match the "tag" condition and display the tag "action-button".

<?php
        if ( is_category() ) :
            single_cat_title();

        elseif ( is_tag() ) :
            echo 'foobar';
            single_tag_title();

        elseif ( is_author() ) :
            /* Queue the first post, that way we know
             * what author we're dealing with (if that is the case).
            */
            the_post();
            printf( __( 'Author: %s', 'upbootwp' ), '<span class="vcard">' . get_the_author() . '</span>' );
            /* Since we called the_post() above, we need to
             * rewind the loop back to the beginning that way
             * we can run the loop properly, in full.
             */
            rewind_posts();

        elseif ( is_day() ) :
            printf( __( 'Day: %s', 'upbootwp' ), '<span>' . get_the_date() . '</span>' );

        elseif ( is_month() ) :
            printf( __( 'Month: %s', 'upbootwp' ), '<span>' . get_the_date( 'F Y' ) . '</span>' );

        elseif ( is_year() ) :
            printf( __( 'Year: %s', 'upbootwp' ), '<span>' . get_the_date( 'Y' ) . '</span>' );

        elseif ( is_tax( 'post_format', 'post-format-aside' ) ) :
            _e( 'Asides', 'upbootwp' );

        elseif ( is_tax( 'post_format', 'post-format-image' ) ) :
            _e( 'Images', 'upbootwp');

        elseif ( is_tax( 'post_format', 'post-format-video' ) ) :
            _e( 'Videos', 'upbootwp' );

        elseif ( is_tax( 'post_format', 'post-format-quote' ) ) :
            _e( 'Quotes', 'upbootwp' );

        elseif ( is_tax( 'post_format', 'post-format-link' ) ) :
            _e( 'Links', 'upbootwp' );

        else :
            _e( 'Design Patterns', 'upbootwp' );

        endif;
    ?>
2
  • Are you certain archive.php is the template in use? Assuming there is no tag template file? Looks like archive.php is one of the last to load by hierarchy.
    – jdm2112
    Commented Aug 25, 2014 at 18:42
  • Yes, I put a piece of text on the page to test.
    – Steve
    Commented Aug 25, 2014 at 22:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.