Support » Plugin: Custom Post Type Permalinks » Found and fixed Bug permalink Struktur

  • Resolved Marcus Franke



    i use your plugin for hirachical Categories in CPT´s.
    The whole Plugin workes fine but its broken in a special case.

    the permalink is wrong when the parent term ID is lower as the sub term.

    u sort the $terms with usort, that is the reason why its broken.
    when u use array_keys and the first entry of the keys array, the Plugin works fine.

    $keys = array_keys($terms);
    $term = $terms[$keys[0]]->slug;
    if ( $parent = $terms[$keys[0]]->parent ) {
    $term = $this->get_taxonomy_parents( $parent,$taxonomy, false, '/', true ) . $term;

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thank you Marcus!

    The code apply next update!

    Hi Toro_unit,

    pls dont put the above code in your plugin.
    Its works not 100%!

    i found some case the hierarchical function are not work with that.
    i do a workarround for 2 level of hierarchical.

    if($terms[0]->parent == 0){
    					$keys = array_keys($terms);
    						$term = $terms[$keys[1]]->slug;
    						if ( $terms[$keys[0]]->term_id == $terms[$keys[1]]->parent ) {
    							$term = $this->get_taxonomy_parents( $terms[$keys[1]]->parent,$taxonomy, false, '/', true ) . $term;
    						$keys = array_keys($terms);
    						$term = $terms[$keys[0]]->slug;
    						if ( $terms[$keys[1]]->term_id == $terms[$keys[0]]->parent ) {
    							$term = $this->get_taxonomy_parents( $terms[$keys[0]]->parent,$taxonomy, false, '/', true ) . $term;

    U can use that for a offical function.
    A solution for the problem could be to sort the term by parent_id.

    i hope it help u out.

    best regards.


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Found and fixed Bug permalink Struktur’ is closed to new replies.