Forums

Error sorting pages by creation (9 posts)

  1. crazydelta
    Member
    Posted 6 years ago #

    Just want to have the pages to show the last page created to be ON TOP.

    I changed
    <?php wp_list_pages('sort_column=menu_order&title_li=<h4>' . __('Pages') . '</h4>' ); ?>

    to this
    <?php wp_list_pages('sort_column=time_created&title_li=<h4>' . __('Pages') . '</h4>' ); ?>

    and after doing so I get this error -

    WordPress database error: [Unknown column 'time_created' in 'order clause']
    SELECT * FROM wp_posts WHERE post_status = 'static' ORDER BY time_created ASC

    Please help!
    Thanks.

  2. Kafkaesqui
    Moderator
    Posted 6 years ago #

    'time_created' was valid only briefly (1.5) for a sort_column value. Try using 'post_date'.

    EDIT: Corrected that particular example on Codex:

    http://codex.wordpress.org/Template_Tags/wp_list_pages

  3. crazydelta
    Member
    Posted 6 years ago #

    OK, thanks. But I want the newest page to be on top.

  4. Kafkaesqui
    Moderator
    Posted 6 years ago #

    "But I want the newest page to be on top."

    Yes, hence post_date = time_created.

  5. crazydelta
    Member
    Posted 6 years ago #

    So i've tried

    <?php wp_list_pages('post_date=time_created&title_li=<h4>' . __('Pages') . '</h4>' ); ?>

    But the result is just that the pages are sorted alphbetically.

  6. Kafkaesqui
    Moderator
    Posted 6 years ago #

    *ahem*

    <?php wp_list_pages('sort_column=post_date&title_li=<h4>' . __('Pages') . '</h4>' ); ?>

    Note what changed above.

  7. crazydelta
    Member
    Posted 6 years ago #

    OH OK. LOL

    But still, I am getting the oldest page on top and the newest on the bottom. I want the other way around.

  8. Kafkaesqui
    Moderator
    Posted 6 years ago #

    <?php wp_list_pages('sort_column=post_date&sort_order=DESC&title_li=<h4>' . __('Pages') . '</h4>' ); ?>

    Good ole' sort_order... :)

  9. crazydelta
    Member
    Posted 6 years ago #

    COOL.
    You da man!

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic