douyue5856 2018-07-17 14:00
浏览 69

我可以在register_taxonomy中重定向而不是重写

Hi currently I show custom taxonomy with:

     $package_category = get_the_term_list( $post->ID, 'package-category', '', ', ' , '' );
        if(!empty($package_category)){
            echo '<div class="package-info">';
            echo '<span class="head">Categories: </span>';
            echo $package_category;
            echo '</div>';
    }   

and

        register_taxonomy(
        "package-category", array("package"), array(
            "hierarchical" => true,
            "label" => "Package Categories", 
            "singular_label" => "Package Categories", 
            "rewrite" => array(
'slug' => '/')));
    register_taxonomy_for_object_type('package-category', 'package');

Currently this lists a bunch of tags with a link to category/package-category/ but the "rewrite" => is causing issues as its actually overwritting category/

Is there a way to redirect to category/ instead of rewrite

  • 写回答

1条回答 默认 最新

  • doujie1908 2018-07-17 20:24
    关注

    I believe I found the answer:

    'rewrite' => array( 
    'slug'          => '.',
    'with_front'    => false 
    ),
    

    worked for me

    评论

报告相同问题?