• Hello guys,

    i’m using a custom function to add .html to my pages & cpt.
    everything works well, except Elementor Pro templates.

    I have find what is creating the bug, but have no idea what i did wrong.

    	function custom_post_permalink( $post_link, $post ) { // Accept $post argument.
    		$post_type                 = get_post_type( $post->ID ); // $post now refers to the one passed as an argument.
    		$post_type_data            = get_post_type_object( $post_type );
    		$post_type_slug            = $post_type_data->rewrite['slug'];
    		$post_type_slug_translated = apply_filters( 'wpml_get_translated_slug', $post_type_slug, $post_type );
    		$translated_home_url       = apply_filters( 'wpml_home_url', home_url() );
    		
    		$be_default_lang_settings = get_option( 'icl_sitepress_settings' );
    		$be_default_lang = $be_default_lang_settings['default_language'];
    		$be_current_lang           = apply_filters( 'wpml_current_language', NULL );
    
    		if ( $be_current_lang === $be_default_lang ) {
    			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', 10, 2 );

    If you have any idea.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    What’s the bug?

    Thread Starter HimSelf (Gregory)

    (@himself)

    Hello @anevins , thank you to take a look to my problem.

    the error is the classic Elementor Error, ” Preview Could Not Be Loaded “.

    article & pages works well. it’s only on creating/editing templates.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Try taking out lines inside your function one by one until the issue goes away. This will help you narrow down what exactly is causing the issue.

    Thread Starter HimSelf (Gregory)

    (@himself)

    If i go to “debug” or “preview” this page, i got a 404. Maybe this info can help ?

    Thread Starter HimSelf (Gregory)

    (@himself)

    @anevins that’s how i identify this function to be in case.
    but all lines is variables, so if i deactive them, got php error.

    If i go to “debug” or “preview” this page, i got a 404. Maybe this info can help ?

    Thread Starter HimSelf (Gregory)

    (@himself)

    Got an idea ^^

    if i look rewrite rules ( with rewrite rules inscpector )

    i see this :

    elementor_library/(.+?)\.html$ index.php?post_type=elementor_library&name=$matches[1] other

    and my preview pages for templates got a double slash ( site.com//preview.html )

    and if i manually go to site.com/elementor_library/preview.html i redirected to original url !

    so i think there is something that delete this part. But what ?

    Thread Starter HimSelf (Gregory)

    (@himself)

    ok, i think i point the problem !

    as said in my last comment, if i deactive this function,
    the preview url is ?elementor_library=preview

    so i suppose that’s where the bug come from.

    now need to figure how to fix it !

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    i’m using a custom function to add .html to my pages & cpt.
    everything works well, except Elementor Pro templates.

    That’s not something we can help you with.

    For pro or commercial product support please contact the author directly on their site. This includes any pre-sales topics as well.

    As the author is aware, commercial products are not supported in these forums. I am sure they will have no problem supporting you there.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Function to modify slug create a bug in elementor pro templates’ is closed to new replies.