Aleluhia !
it was because $type don’t use WPML function
Here is the code that works perfectly with WPML and translated slug :
// .html pour les customs posts
function rewrite_rules($rules) {
$new_rules = array();
foreach (get_post_types() as $t)
$new_rules[$t . '/(.+?)\.html$'] = 'index.php?post_type=" . $t . "&name=$matches[1]';
return $new_rules + $rules;
}
add_action('rewrite_rules_array', 'rewrite_rules');
function custom_post_permalink ($post_link) {
global $post;
if ( $post ) {
$type = get_post_type($post->ID);
$slug = apply_filters( 'wpml_get_translated_slug',$type,$type,'');
return home_url() . "https://wordpress.stackexchange.com/" . $slug . "https://wordpress.stackexchange.com/" . $post->post_name . '.html';
}
}
add_filter('post_type_link', 'custom_post_permalink'); // for cpt post_type_link (rather than post_link)
Related Posts:
- Remove slug from custom post type post URLs
- Theme localization of “slugs” (custom post types, taxonomies)
- How do I get a post (page or CPT) ID from a title or slug?
- How to get custom post type label and singular label from its slug?
- Disable permalink on custom post type
- Using Custom Fields in Custom Post Type URL
- Change slug of registered custom post type in child theme
- Custom Post Type With Different Views
- Dynamic taxonomy in permalink made all other posts NOT FOUND?
- Post slug changed using code doesn’t reflect on editor when post is published
- How to achieve this permalink -> category-name/custom-post-type-name/post-name
- Prepend meta_value to permalink of post
- Reslug a Custom Post Type
- Removing CPT slug from URL results in 404 error for archive page
- Getting Post ID from slug during init
- Remove taxonomy slug when not assigning taxonomy with custom post types
- Custom post type’s slug gets wrong when adding a custom meta box
- Unable to display multiple post types in same query (WPML WP_Query)
- Can’t edit Custom Post Type slug/permalink
- Custom Permalink with Dynamic Taxonomy for Custom Post Type – Works, but breaks other permalinks
- Custom Post Type with two hierarchical Custom Taxonomies: strategy to generate best permalink structure
- Custom post type with slug for plural (archive) and for single
- Automaticly add slug to posts
- Fetch ID’s associated with a custom post type when translated with WPML?
- How do I fix permalinks for custom post types that has the same slug as a page?
- Custom post types archive redirect
- Why does wordpress keep adding postname to my CPT’s permalink in the end?
- Remove post type slug of all post types from permalinks
- CPT custom archive template does not get loaded
- Am I using the flush_rewrite_rules function in the right place?
- Rewrite slug for CPT
- Getting a PHP Notice when using Pods with WPML [closed]
- Is there a way to have custom post type and page with the same slug?
- Using Same Slug With Multiple Post Types
- Rewrite post type slug only for child theme
- Child post with numeric only slug keeps redirecting to parent
- Adding Post id to the end of slug in a Custom Post Type
- Remove the parent slug in a CPT URL
- Permalink for a custom post type isn’t working and I don’t know why
- Index page with the same id as the slug
- How can I make the slug of the taxonomy also the slug of the custom post
- Assign same parrent Page to pages AND custom post types
- Multiple (two) category postings on the same page.
- Removed custom post type slug but not working for child pages
- Fixed values for same post translations
- Can slugs from posts and custom post types conflict?
- Custom Post Type – Duplicate Page Slugs
- Remove permalink for custom post type
- How to make a posttype show under a page hierarchy (example.com/page/posttype/entry)?
- Custom Post Type archive-{post-type}.php not working
- Custom post type single page (single-{CPT-name}) 404 when slug includes hyphens
- Slug for custom post type
- Rename a slug label
- How to add current custom taxonomy slug to body class
- Using page slug in wp_query
- Listing all slugs?
- Why WordPress is picking archive.php instead of page.php?
- WordPress Custom Post Type – Rewrite Query
- How to migrate Custom Field Template to a WordPress Multisite
- Automatically update slug with latest title within custom post type [duplicate]
- How to use a specific custom field in a custom post type as slug
- sort by name (slug) custom post type
- How to controll the Posts post type and general wondering about WP data structure
- How to change CPT single post slug
- How do I set a post slug automatically based on taxonomy?
- Custom Post type dont use custom page template (slug is not right)
- Difference between a default post type and a custom post type?
- How can I write slugs / permalinks as: custom post type -> custom taxonomy and custom post type -> custom taxonomy (one CPT and many taxo)?
- Custom Post Type not using correct page template
- Change permalink incrementor into pseudo-subdirectory
- Custom Post Type slug and WPML gets 404 error
- Custom post type URL structure with site.com/custom_taxonomy_slug/post_name
- Custom Post Type duplicating slug for new posts
- WP gives 404 error for custom post type with GET variable
- Custom taxonomy archive slug overwrites static page
- Slugs on hierarchical taxonomies
- Getting a 404 on single custom post type page when using rewrite on a custom taxonomy
- WPML – Auto Duplicate Post Issue
- Generate slug and meta data if meta field is empty
- Get full control over custom post type url
- Add category slug as class attribute in a link array
- Relationship with 2 custom post types
- Costum post type with costum (sub)taxonomy
- Remove Custom Taxonomy Slug only without removing Custom post type slug in permalinks
- Category slug not showing for Custom Post Type
- WP Query WordPress Post Type with the same Taxonomy name
- Custom Post Type Slug / Page Slug Conflict – Prevent use of reserved slug on page save?
- Ideal top-level slug methods
- WordPress pagination URL
- is this a bug or not?
- Create page using same slug as custom post type
- Custom Post Type with multiple Custom Taxonomies / Hide Taxonomy Slug from URL
- Same slug for Custom Taxonomy archive and CPT archive – Rewrite rule not working
- Removing custom post type name from permalink
- Custom Post Type slug has the same Redirection entry
- How to change rewrite slug for custom post type without conflicting w/ child pages of page with same slug
- Custom post type URl Cutomization
- Right Permalink for Custom Post Type with number slug
- Custom post type slug localization
- How to get taxonomy category in permalink for each taxonomy OR How to give a parent page to a given taxonomy?