_wp_mysql_week example


                $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 );
            }
        }
    } elseif ( 'weekly' === $parsed_args['type'] ) {
        $week    = _wp_mysql_week( '`post_date`' );
        $query   = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `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' );
        }
        $arc_w_last = '';
        if ( $results ) {
            $after = $parsed_args['after'];
            
'WEEKDAY'        => array( 'dayofweek_iso' ),
        );

        // Check of the possible date units and add them to the query.         foreach ( $date_units as $sql_part => $query_parts ) {
            foreach ( $query_parts as $query_part ) {
                if ( isset( $query[ $query_part ] ) ) {
                    $value = $this->build_value( $compare$query[ $query_part ] );
                    if ( $value ) {
                        switch ( $sql_part ) {
                            case '_wp_mysql_week':
                                $where_parts[] = _wp_mysql_week( $column ) . " $compare $value";
                                break;
                            case 'WEEKDAY':
                                $where_parts[] = "$sql_part( $column ) + 1 $compare $value";
                                break;
                            default:
                                $where_parts[] = "$sql_part( $column ) $compare $value";
                        }

                        break;
                    }
                }
            }
Home | Imprint | This part of the site doesn't use cookies.