最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

categories - How to set the same base url for two different taxonomies?

programmeradmin1浏览0评论

I have created two custom taxonomies.

function themename_custom_taxonomies() {
    // Coaching Method

    $nieruchomosc = array(
        'name' => _x( 'Nieruchomość', 'taxonomy general name' ),
        'singular_name' => _x( 'Nieruchomość', 'taxonomy singular name' ),
        'search_items' =>  __( 'Szukaj nieruchomości' ),
        'all_items' => __( 'Wszystkie nieruchomości' ),
        'most_used_items' => null,
        'parent_item' => null,
        'parent_item_colon' => null,
        'edit_item' => __( 'Edytuj' ), 
        'update_item' => __( 'Zapisz' ),
        'add_new_item' => __( 'Dodaj nieruchomość' ),
        'new_item_name' => __( 'Nowa nieruchomość' ),
        'menu_name' => __( 'Nieruchomości' ),
    );
    $args = array(
        'hierarchical' => true,
        'labels' => $nieruchomosc,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array('slug' => 'nieruchomosc', 'with_front' => false)
    );
    register_taxonomy( 'nieruchomosc', array( 'nieruchomosc', 'ogloszenia' ), $args );

    $rodzaj_oferty = array(
        'name' => _x( 'Rodzaj oferty', 'taxonomy general name' ),
        'singular_name' => _x( 'Rodzaj oferty', 'taxonomy singular name' ),
        'search_items' =>  __( 'Wybierz rodzaj oferty' ),
        'all_items' => __( 'Wszystkie rodzaje' ),
        'most_used_items' => null,
        'parent_item' => null,
        'parent_item_colon' => null,
        'edit_item' => __( 'Edytuj' ), 
        'update_item' => __( 'Zapisz' ),
        'add_new_item' => __( 'Dodaj rodzaj' ),
        'new_item_name' => __( 'Nowy rodzaj oferty' ),
        'menu_name' => __( 'Rodzaj oferty' ),
    );
    $args = array(
        'hierarchical' => true,
        'labels' => $rodzaj_oferty,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array('slug' => 'oferta', 'with_front' => false)
    );
    register_taxonomy( 'oferta', array( 'oferta', 'ogloszenia' ), $args );
    
    
}
add_action( 'init', 'themename_custom_taxonomies', 0 );

And now they look like: for taxonomy called 'oferta'

example/oferta/slug_single_tax_oferta

for taxonomy called 'nieruchomosc'

example/nieruchomosc/slug_single_tax_nieruchomosc

Is it possible that I will be able to see them with:

for 'oferta', 'nieruchomosc':

example/ogloszenia/slug_single_tax_oferta
example/ogloszenia/slug_single_tax_nieruchomosc

Because page called /ogloszenia/ is my page with lisitngs. And I would like to show it based on this permalink.

Of course the taxnomies will be unique.

I tried to set for each taxonomy:

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

But it worked only for 'nieruchomosc' but for 'oferta' I got error 404 for taxnomies.

Could somone help me with it? Thank you in advance.

发布评论

评论列表(0)

  1. 暂无评论