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.com/oferta/slug_single_tax_oferta

for taxonomy called 'nieruchomosc'

example.com/nieruchomosc/slug_single_tax_nieruchomosc

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

for 'oferta', 'nieruchomosc':

example.com/ogloszenia/slug_single_tax_oferta
example.com/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.

2
  • This isn’t going to work because WordPress can’t tell what term to look for the slug in. If the URL slug is the same, then why do they need to be separate taxonomies? Feb 5 at 13:25
  • That why I asked if it is possible. Because I think there is possibility and I guees it is possible to do with "url-rewriting" but I do not know too much about it.
    – kibus90
    Feb 5 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.