如何在Wordpress中更改自定义分类的URL?

时间:2012-03-09 20:11:35

标签: wordpress

我的主题(Wordpress)中有自定义帖子和分类。我可以添加帖子属于组合,服务和滑块类别(自定义分类),然后像这样的网址显示:

www.heptasarim.com/的组合 /my-portfolio.html

但我想像这样显示网址:

www.heptasarim.com/的 referans /my-portfolio.html

网站:heptasarim.com

我的自定义邮政编码是:

    //Slider post type registration
add_action('init', 'slider_register');

function slider_register() {
    $args = array(
        'label' => __('Slideshow'),
        'singular_label' => __('Slideshow'),
        'publicly_queryable' => true,
        'query_var' => true,
        'public' => true,
        'show_ui' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'rewrite' => true,
        'supports' => array('title', 'editor', 'thumbnail'),
        'menu_icon' => get_template_directory_uri(). '/images/admin/slideshow.png',
    );

    register_post_type('slider', $args);
}

register_taxonomy("slidercatalog", array("slider"), array("hierarchical" => true, "label" => "Catalogs", "singular_label" => "Catalog", "rewrite" => true));
add_filter("manage_edit-slider_columns", "slider_edit_columns");
add_action("manage_posts_custom_column", "slider_custom_columns");

function slider_edit_columns($columns) {
    $columns = array(
        "cb" => "<input type=\"checkbox\" />",
        "title" => "Slider Title",
        "catalog" => "Catalog",
        "date" => "date",
    );
    return $columns;
}

function slider_custom_columns($column) {
    global $post;
    switch ($column) {
        case "description":
            the_excerpt();
            break;
        case "catalog":
            echo get_the_term_list($post->ID, 'slidercatalog', '', ', ', '');
            break;
    }
}

1 个答案:

答案 0 :(得分:3)

永久链接是由slug决定的,所以你想要这样注册:

register_taxonomy(
    "slidercatalog", 
    array("slider"), 
    array(
        "hierarchical"   => true, 
        "label"          => "Catalogs", 
        "singular_label" => "Catalog", 
        "rewrite"        => true, 
        "slug"           => "referans"
    )
);