is_year example


function is_year() {
    global $wp_query;

    if ( ! isset( $wp_query ) ) {
        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
        return false;
    }

    return $wp_query->is_year();
}

/** * Determines whether the query has resulted in a 404 (returns no results). * * For more information on this and similar theme functions, check out * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ * Conditional Tags} article in the Theme Developer Handbook. * * @since 1.5.0 * * @global WP_Query $wp_query WordPress Query object. * * @return bool Whether the query is a 404 error. */
<?php get_search_form(); ?> </li> <!-- Author information is disabled per default. Uncomment and fill in your details if you want to use it. <li><h2><?php _e( 'Author' ); ?></h2> <p>A little something about you, the author. Nothing lengthy, just an overview.</p> </li> --> <?php                 if ( is_404() || is_category() || is_day() || is_month() ||
                is_year() || is_search() || is_paged() ) :
                    ?> <li> <?php if ( is_404() ) : /* If this is a 404 page */ ?> <?php elseif ( is_category() ) : /* If this is a category archive */ ?> <p> <?php                     printf(
                        /* translators: %s: Category name. */
                        __( 'You are currently browsing the archives for the %s category.' ),
                        single_cat_title( '', false )
                    );
// If on a category or tag archive, use the term title.     } elseif ( is_category() || is_tag() ) {
        $title['title'] = single_term_title( '', false );

        // If on an author archive, use the author's display name.     } elseif ( is_author() && get_queried_object() ) {
        $author         = get_queried_object();
        $title['title'] = $author->display_name;

        // If it's a date archive, use the date as the title.     } elseif ( is_year() ) {
        $title['title'] = get_the_date( _x( 'Y', 'yearly archives date format' ) );

    } elseif ( is_month() ) {
        $title['title'] = get_the_date( _x( 'F Y', 'monthly archives date format' ) );

    } elseif ( is_day() ) {
        $title['title'] = get_the_date();
    }

    // Add a page number if necessary.     if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
        
 {
            $redirect_url = home_url( '/' );
        } elseif ( is_home() && ! empty( $_GET['page_id'] ) && ! $redirect_url
            && 'page' === get_option( 'show_on_front' ) && get_query_var( 'page_id' ) === (int) get_option( 'page_for_posts' )
        ) {
            $redirect_url = get_permalink( get_option( 'page_for_posts' ) );
            $redirect_obj = get_post( get_option( 'page_for_posts' ) );

            if ( $redirect_url ) {
                $redirect['query'] = remove_query_arg( 'page_id', $redirect['query'] );
            }
        } elseif ( ! empty( $_GET['m'] ) && ( is_year() || is_month() || is_day() ) ) {
            $m = get_query_var( 'm' );

            switch ( strlen( $m ) ) {
                case 4: // Yearly.                     $redirect_url = get_year_link( $m );
                    break;
                case 6: // Monthly.                     $redirect_url = get_month_link( substr( $m, 0, 4 )substr( $m, 4, 2 ) );
                    break;
                case 8: // Daily.                     $redirect_url = get_day_link( substr( $m, 0, 4 )substr( $m, 4, 2 )substr( $m, 6, 2 ) );
                    
Home | Imprint | This part of the site doesn't use cookies.