Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: Problem of order with “the_category”

Discussion in 'Misc WordPress Requests' started by yopyop22, Jan 30, 2018.

  1. yopyop22

    Guest

    Reply To: Problem of order with “the_category”, by yopyop22

    i find a soltuion and is working

    <?php
    $categories = get_the_category();

    $ordering = array();
    foreach( $categories as $index => $cat) {
    $ordering[$cat->parent] = $index;
    }

    $ordered_string = “”;
    $i = 0;
    while( $ordering[$i] !== null ){
    $ordered_string .= ‘term_id ).'”>’.$categories[$ordering[$i]]->name.’ -> ‘;

    $i = $categories[$ordering[$i]]->term_id;
    }

    echo $ordered_string;
    ?>

    Now i have only one problem i want to show only the last one ???

    Reply To: Problem of order with “the_category”
     
    #1

Share This Page

Monarch Social Sharing Plugin