daily pastebin goal
59%
SHARE
TWEET

Untitled

a guest Mar 21st, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // .html pour les customs posts
  2.  
  3. function rewrite_rules($rules) {
  4.     $new_rules = array();
  5.     foreach (get_post_types() as $t)
  6.     $new_rules[$t . '/(.+?)\.html$'] = 'index.php?post_type=' . $t . '&name=$matches[1]';
  7.     return $new_rules + $rules;
  8. }
  9. add_action('rewrite_rules_array', 'rewrite_rules');
  10.  
  11. function custom_post_permalink ($post_link) {
  12.     global $post;
  13.     if ( $post ) {
  14.         $type = get_post_type($post->ID);
  15.         $slug = apply_filters( 'wpml_get_translated_slug',$type,$type,'');
  16.         return home_url() . '/' . $slug . '/' . $post->post_name . '.html';
  17.     }
  18. }
  19. add_filter('post_type_link', 'custom_post_permalink'); // for cpt post_type_link (rather than post_link)
RAW Paste Data
Top