WordPress.org

Support

Support » Plugins and Hacks » Hacks » [Resolved] Pages and post taxonomy pretty URL

[Resolved] Pages and post taxonomy pretty URL

  • 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.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Pages and post taxonomy pretty URL’ is closed to new replies.
Skip to toolbar