Created
January 4, 2012 09:21
-
-
Save jmslbam/1559261 to your computer and use it in GitHub Desktop.
Custom Post Type Archive with WPML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Template Name: News Archive */ | |
?> | |
<?php | |
include('archive.php'); | |
?> | |
<?php | |
/* don't forget to put these in your functions.php */ | |
function add_rules($wp_rewrite) { | |
$new_rules = array( | |
'news/([^/]+)/?$' => 'index.php?post=' . $wp_rewrite->preg_index(1), | |
); | |
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules; | |
} | |
add_filter('generate_rewrite_rules', 'add_rules'); | |
function filter_cpt_link($str) { | |
if ( ICL_LANGUAGE_CODE == 'en' ) { | |
$str = preg_replace('|/actu/|', '/news/', $str); | |
} | |
return $str; | |
} | |
add_filter('post_type_link', 'filter_cpt_link'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment