WordPress.org

Ready to get started?Download WordPress

Forums

modify output of get_{$adjacent}_post_sort (4 posts)

  1. victor_d
    Member
    Posted 2 years ago #

    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

  2. victor_d
    Member
    Posted 2 years ago #

    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

  3. victor_d
    Member
    Posted 2 years ago #

    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

  4. leian
    Member
    Posted 2 years ago #

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

    Yan

Topic Closed

This topic has been closed to new replies.

About this Topic