WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Pages and post taxonomy pretty URL (3 posts)

  1. sebastienlavoie
    Member
    Posted 1 year ago #

    I have to ship different pages and, on a blog section, different posts according to a country taxonomy. So a page could show up in USA and Canada and another one could show up in France and Italy depending on what countries the author has checked. Users get content associated with their country.

    What I would like to have is URLs like :

    http://mywebsite.com/country-value/my-page-name
    http://mywebsite.com/country-value/my-post-name

    I registered a custom taxonomy :

    $labels = array(
    'name' => 'Country'
    );

    $args = array(
    'labels' => $labels,
    'public' => true,
    'show_in_nav_menus' => false,
    'show_ui' => true,
    'hierarchical' => true,
    'rewrite' => true
    );

    register_taxonomy( 'country', array('page', 'post'), $args );

    I googled around and did not find much talking about how to automatically format pages slugs. I tried changing permalinks using %country% but, as I expected, it didn't do anything.

    What would I have to do to rewrite pages slugs dynamically and add the value of my country taxonomy before the slug? Or am I just doing it wrong?

    Thanks.

  2. bcworkz
    Member
    Posted 1 year ago #

    Have you looked over Rewrite API? You should be able to get something working using it.

  3. sebastienlavoie
    Member
    Posted 1 year ago #

    Okay finally I decided to go with a multisite setup, it gives me more option for the future. Thanks ;)

Topic Closed

This topic has been closed to new replies.

About this Topic