Forums

List Archives By Year creates sql error after 2.1 update (3 posts)

  1. jordantbro
    Member
    Posted 5 years ago #

    This code now causes a sql problem after the 2.1 install and database update.

    Found http://codex.wordpress.org/Creating_an_Archive_Index

    Snippet:

    • Archives
      • <?php
        $years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date DESC");
        foreach($years as $year) : ?>

      • "><?php echo $year; ?>
      • <?php endforeach; ?>

    Error message:

    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY cat_name ASC' at line 1]
    SELECT cat_id, cat_name FROM ORDER BY cat_name ASC

  2. Andrew Charlton
    Member
    Posted 5 years ago #

    The code you posted isn't throwing that error, post up the part that is or email me the file, froman118 at gmail.com

  3. Kafkaesqui
    Moderator
    Posted 5 years ago #

    Any chance this thread is of help?

    http://wordpress.org/support/topic/102888

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags