Support

Account

Home Forums Front-end Issues relationship – impossible to get permalink Reply To: relationship – impossible to get permalink

  • Hello,

    after many investigation, i found what is making this trouble !

    its a custom code i used to add a .html extension to all my pages & customs posts.

    but i can not figure what in this code is creating this trouble :s

    my function

    	function custom_post_permalink ($post_link) {
    		global $post;
    		if($post) {
    			$type = get_post_type($post->ID);
    			$post_type_data = get_post_type_object( $type );
    			$post_type_slug = $post_type_data->rewrite['slug'];
    			$post_type_slug_translated = apply_filters( 'wpml_get_translated_slug', $post_type_slug, $type);
    			$translated_home_url = apply_filters( 'wpml_home_url', home_url());
    			$be_current_lang = apply_filters( 'wpml_current_language', NULL );
    			if($be_current_lang=='fr'){
    				return $translated_home_url . $post_type_slug_translated . '/' . $post->post_name . '.html';
    			} else {	
    			return $translated_home_url .'/'. $post_type_slug_translated . '/' . $post->post_name . '.html';
    			}
    		}
    	}
    	add_filter('post_type_link', 'custom_post_permalink');

    Thanks in advance for your help