get_month_link example


        }

        $year  = get_query_var( 'year' );
        $month = get_query_var( 'monthnum' );
        $day   = get_query_var( 'day' );

        if ( $year && $month && $day ) {
            $date = sprintf( '%04d-%02d-%02d', $year$month$day );

            if ( ! wp_checkdate( $month$day$year$date ) ) {
                $redirect_url = get_month_link( $year$month );

                $redirect['query'] = _remove_qs_args_if_not_in_url(
                    $redirect['query'],
                    array( 'year', 'monthnum', 'day' ),
                    $redirect_url
                );
            }
        } elseif ( $year && $month && $month > 12 ) {
            $redirect_url = get_year_link( $year );

            $redirect['query'] = _remove_qs_args_if_not_in_url(
                
$query   = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order $limit";
        $key     = md5( $query );
        $key     = "wp_get_archives:$key:$last_changed";
        $results = wp_cache_get( $key, 'post-queries' );
        if ( ! $results ) {
            $results = $wpdb->get_results( $query );
            wp_cache_set( $key$results, 'post-queries' );
        }
        if ( $results ) {
            $after = $parsed_args['after'];
            foreach ( (array) $results as $result ) {
                $url = get_month_link( $result->year, $result->month );
                if ( 'post' !== $parsed_args['post_type'] ) {
                    $url = add_query_arg( 'post_type', $parsed_args['post_type']$url );
                }
                /* translators: 1: Month name, 2: 4-digit year. */
                $text = sprintf( __( '%1$s %2$d' )$wp_locale->get_month( $result->month )$result->year );
                if ( $parsed_args['show_post_count'] ) {
                    $parsed_args['after'] = ' (' . $result->posts . ')' . $after;
                }
                $selected = is_archive() && (string) $parsed_args['year'] === $result->year && (string) $parsed_args['monthnum'] === $result->month;
                $output  .= get_archives_link( $url$text$parsed_args['format']$parsed_args['before']$parsed_args['after']$selected );
            }
        }
Home | Imprint | This part of the site doesn't use cookies.