Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  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. $post_type_data = get_post_type_object( $type );
  16. $post_type_slug = $post_type_data->rewrite['slug'];
  17. $post_type_slug_translated = apply_filters( 'wpml_get_translated_slug', $post_type_slug, $type, ICL_LANGUAGE_CODE);
  18. return home_url() . '/' . $post_type_slug_translated . '/' . $post->post_name . '.html';
  19. }
  20. }
  21. add_filter('post_type_link', 'custom_post_permalink'); // for cpt post_type_link (rather than post_link)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement