• Resolved uroosa

    (@uroosa)


    Hi again ??

    We have age ranges defined as a custom taxonomy via your plugin. Since the ranges – 0-4, 12-14, 15+, 4-7, 7-10, 9-12 – are strings, they are listed in the funny order that you see above, on the admin side of the custom book post and then subsequently presented as such to the user on our book description page. Is there a way around this that would solve the ordering on the admin side as well as the output to the user? If not, then at least to the user? We would want the age ranges to be presented as 0-4, 4-7, 7-10, 9-12, 12-14, 15+ – ascending order looking at the first number before the dash.

    Presently, we are on 1.44.0.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Kemory Grubb

    (@w33zy)

    You could use the PHP’s natcasesort() function to do a natural case sort.

    Thread Starter uroosa

    (@uroosa)

    This did it thank you! In case anyone else needs this, I just needed to get the terms without the tags, explode into an array, natcasesort, implode and then output with tags.

    //$terms = get_the_term_list( $review_id, $taxonomy, ‘<span class=”rcno-tax-term”>’, $sep, ‘</span>’ );
    //moved tags to line 1018 where output is being set with terms since the tags were interfering with sort below.

    $terms = get_the_term_list( $review_id, $taxonomy, ”, $sep, ” );
    if ($taxonomy === ‘rcno_age’) {
    $sortedarray = explode(‘,’, $terms);
    natcasesort($sortedarray);
    $terms=implode(‘,’, $sortedarray);
    }
    .
    .
    .
    if ( $terms && ! is_wp_error( $terms ) ) {

    $out .= sprintf(

    ‘<div class=”rcno-term-list”>%1s%2s</div>’,

    $prefix,

    ‘<span class=”rcno-tax-term”>’ . $terms . ‘</span>’

    );

    $out .= ”;

    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Age Ranges’ is closed to new replies.