Forums

Shouldn't classes.php's get_posts() use $start_of_week instead of assuming 1? (1 post)

  1. shadytrees
    Member
    Posted 6 years ago #

    if ( (int) $q['w'] ) {
    $q['w'] = ''.intval($q['w']);
    $where .= " AND WEEK(post_date, 1)='" . $q['w'] . "'";
    }

    I know $start_of_week doesn't exist yet at that code (get_posts(), classes.php) but assuming "1" seems to break my weekly archives. It seems to have been fixed when I change it to 0 (which is the setting I have in the Options panel and what $start_of_week should be if it existed). Other SQL queries with WEEK() in them seem to use $start_of_week consistently, such as

    $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS week, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);

    in template-functions-general.php.

    The WEEK() MYSQL function documentation is
    http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html
    if anybody wants to see it.

    I'm using WordPress 2.0.2, PHP 5, MYSQL 5, Apache 2, the whole shebang.

Topic Closed

This topic has been closed to new replies.

About this Topic