get_day_link example

 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 ) );
                    break;
            }

            if ( $redirect_url ) {
                $redirect['query'] = remove_query_arg( 'm', $redirect['query'] );
            }
            // Now moving on to non ?m=X year/month/day links.         } elseif ( is_date() ) {
            $year  = get_query_var( 'year' );
            $month = get_query_var( 'monthnum' );
            $day   = get_query_var( 'day' );

            
$query   = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(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_day_link( $result->year, $result->month, $result->dayofmonth );
                if ( 'post' !== $parsed_args['post_type'] ) {
                    $url = add_query_arg( 'post_type', $parsed_args['post_type']$url );
                }
                $date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth );
                $text = mysql2date( get_option( 'date_format' )$date );
                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 && (string) $parsed_args['day'] === $result->dayofmonth;
                $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.