Quantcast
Channel: polylang – WordPress.org Forums
Viewing all articles
Browse latest Browse all 11471

norboo on "[Plugin: Polylang] Slug rewrite for Custom Post Types and Custom Taxonomies"

$
0
0

Hi!
I've been trying to build a bilingual website (English and Chinese) and it works perfect with an exception: the rewrites for CPTs and custom taxonomies.

The structure I have right now is:
http://www.domain.com/en/products/cat1/prod1
http://www.domain.com/zh/products/cat1-zh/prod1-zh where "products" is a page with a custom template to hold all the "product_categories"

and I'd like to have:
http://www.domain.com/en/products/cat1/prod1
http://www.domain.com/zh/products-zh/cat1-zh/prod1-zh or even better http://www.domain.com/中文/products-zh/cat1-zh/prod1-zh (translating the language code too)

This is what I tried but it doesn't work. The "products" gets translated after the rewrite is outputed.

pll_register_string('Products Slug','products');
function register_taxonomy_product_categories() {
    ......
    $args = array(
        'hierarchical' => true,
        'rewrite' => array('slug'=>pll__('products'),
    );

    register_taxonomy( 'product_categories', array('products'), $args );
}

add_action( 'init', 'register_cpt_products' );

function register_cpt_products() {
        .....
	$args = array(
		'hierarchical' => false,
		'taxonomies' => array( 'product_categories' ),
		'has_archive' => false,
		'rewrite' => array('permastruct'=>pll__('products').'/%product_categories%/%postname%'),
		'capability_type' => 'post'
	);

	register_post_type( 'products', $args );
}

Any leads and suggestions will be greatly appreciated!

http://wordpress.org/plugins/polylang/


Viewing all articles
Browse latest Browse all 11471

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>