Support » Themes and Templates » modify output of get_{$adjacent}_post_sort

  • Hi!

    i want to sort the output of get_{$adjacent}_post_sort in link-template.php(l:1100) with ‘menu_order’ instead of ‘post_date’.

    i’m using wordpress as a cms with no posts, just pages.
    Therefor i want the next/prev links and link rel next/prev according to the page hierachy instead creation time of the pages.

    in link-template.php
    $sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1" );

    simply changing p.post_date to p.menu_order – unfortunately does not work 🙂

    if someone could help, i would be glad!

    victor

Viewing 3 replies - 1 through 3 (of 3 total)
  • me again,

    i think i could handle it if i would get to the actual menu_order id. From there, I, theoretecly, just had to add +1.

    Any Ideas?

    Greetings

    victor

    ha! i got it.

    Sometimes it’s good talking to himself 😉

    so, for those of you who were looking for something like this, you should add a new var in the link-template.php
    $actualmoID = $post->menu_order; // gets actual ID in current menu order
    then change

    $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare("WHERE p.post_date $op %s AND p.post_type = %s AND p.post_status = 'publish' $posts_in_ex_cats_sql", $current_post_date, $post->post_type), $in_same_cat, $excluded_categories );
    $sort  = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1" );

    to

    $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare("WHERE p.menu_order $op $actualmoID AND p.post_type = 'page' AND p.post_status = 'publish' $posts_in_ex_cats_sql", $current_post_date, $post->post_type), $in_same_cat, $excluded_categories );
    $sort  = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.menu_order $order LIMIT 1" );

    have fun!

    victor

    It works great, thank you very much for sharing Victor !

    Yan

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘modify output of get_{$adjacent}_post_sort’ is closed to new replies.