Support » Plugin: Advanced Recent Posts Widget » Option to sort by post slug

Viewing 2 replies - 1 through 2 (of 2 total)
  • Ok, I tried replacing
    <option value="title"<?php selected( $instance["sort_by"], "title" ); ?>>Title</option>
    with
    <option value="name"<?php selected( $instance["sort_by"], "name" ); ?>>Name (post slug)</option>

    See: http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters

    This should have caused the orderby variable for the $my_args to be “name” instead of “title” in the WP_Query.

    But it didn’t work. The recent post now are just ordered by date but reverse.

    PS: I looked up the values in the database and it clearly states:
    s:7:”sort_by”;s:4:”name”;

    Yay, I got it.

    You also need to change the following line:
    $default_sort_orders = array('date', 'title', 'comment_count', 'rand');
    to
    $default_sort_orders = array('date', 'name', 'comment_count', 'rand');

    Or maybe not. 😉 It works now. 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Option to sort by post slug’ is closed to new replies.