PHP code example of davidwebca / wp-polylang-translate-rewrite-slugs

1. Go to this page and download the library: Download davidwebca/wp-polylang-translate-rewrite-slugs library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

davidwebca / wp-polylang-translate-rewrite-slugs example snippets


add_filter('pll_translated_post_type_rewrite_slugs', function($post_type_translated_slugs) {
	// Add translation for "product" post type.
	$post_type_translated_slugs = array(
		'product' => array(
			'fr' => array(
				'has_archive' => true,
				'rewrite' => array(
					'slug' => 'produit',
				),
			),
			'en' => array(
				'has_archive' => true,
				'rewrite' => array(
					'slug' => 'product',
				),
			),
		),
	);
	return $post_type_translated_slugs;
});