Support » Plugin: Permalink Manager Lite » Wrong redirect when using Elementor default “Landing page” post type

  • Resolved jigglypuffz

    (@jigglypuffz)


    Using permalink manager Pro (of course!)

    When creating a page using elementor default “Landing page” post type, when a user try to accesss the page, the prefix get stripped and the user get redirected to the permalink itself.

    ex:

    /landing-page/this-is-my-page/
    redirect to:
    /this-is-my-page/

    Absolutely no idea how to debug this, tryed changing the prefix etc but no results.

    Any help would be appreciated.

    Thanks !

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Maciej Bis

    (@mbis)

    Could you add “?debug_url=1” and “?debug_redirect=1” to any landing page URL and send me the screenshots of both debug screens?

    Please also note that this support board is intended for Lite version only, if you are using paid version please use the contact form on the plugin’s website:
    https://permalinkmanager.pro/contact/

    Plugin Author Maciej Bis

    (@mbis)

    I ran some tests on this on my server, and I was able to successfully replicate the issue. In general, the landing pages are saved by Elementor using its AJAX functions, therefore Permalink Manager cannot generate their permalinks by default.

    To get it working, you will need to use the below code snippet.

    function pm_set_landing_page_uri($return_data, $document) {
    	global $permalink_manager;
    
    	if(empty($permalink_manager)) {
    		$permalink_manager = new Permalink_Manager_Class();
    	}
    
    	// Get post object
    	$post = $document->get_main_post();
    
    	// Update only selected post type permalinks
      if(!empty($post->post_type) && $post->post_type !== 'e-landing-page') {
    		return $return_data;
    	}
    
    	if(class_exists('Permalink_Manager_URI_Functions_Post')) {
    		// Get current custom permalink (if any)
    		$custom_uri = Permalink_Manager_URI_Functions_Post::get_post_uri($post->ID, false, true);
    
    		// Trigger only if no custom permalink was saved earlier
    		if(empty($custom_uri)) {
    			// Get the default URI
    			$default_uri = Permalink_Manager_URI_Functions_Post::get_default_post_uri($post->ID);
    
    			// Save the default URI
    			Permalink_Manager_URI_Functions::save_single_uri($post->ID, $default_uri, false, true);
    		}
    	}
    
    	return $return_data;
    }
    add_filter('elementor/documents/ajax_save/return_data', 'pm_set_landing_page_uri', 10, 2);
    Thread Starter jigglypuffz

    (@jigglypuffz)

    Thanks for the quick reply !

    I added the code to our functions.php but not dont seem to work, here is the debug

    debug url:

    Array
    (
        [uri_parts] => Array
            (
                [lang] => en
                [uri] => e-landing-page/test-lp-elementor
                [endpoint] => 
                [endpoint_value] => 
            )
    
        [old_query_vars] => Array
            (
                [page] => 
                [e-landing-page] => test-lp-elementor
                [post_type] => e-landing-page
                [name] => test-lp-elementor
            )
    
        [new_query_vars] => Array
            (
                [name] => test-lp-elementor
                [post_type] => e-landing-page
                [e-landing-page] => test-lp-elementor
                [do_not_redirect] => 1
            )
    
        [pm_query] => 52892
        [content_type] => Post type: e-landing-page
        [license_key] => ***-***-171594
        [version] => 2.2.18
    )

    debug redirect (page get redirected before it yield the output):

    Array
    (
        [query_vars] => Array
            (
                [no_found_rows] => 1
                [post_type] => e-landing-page
                [error] => 
                [m] => 
                [p] => 52892
                [post_parent] => 
                [subpost] => 
                [subpost_id] => 
                [attachment] => 
                [attachment_id] => 0
                [pagename] => 
                [page_id] => 
                [second] => 
                [minute] => 
                [hour] => 
                [day] => 0
                [monthnum] => 0
                [year] => 0
                [w] => 0
                [category_name] => 
                [tag] => 
                [cat] => 
                [tag_id] => 
                [author] => 
                [author_name] => 
                [feed] => 
                [tb] => 
                [paged] => 0
                [meta_key] => 
                [meta_value] => 
                [preview] => 
                [s] => 
                [sentence] => 
                [title] => 
                [fields] => 
                [menu_order] => 
                [embed] => 
                [category__in] => Array
                    (
                    )
    
                [category__not_in] => Array
                    (
                    )
    
                [category__and] => Array
                    (
                    )
    
                [post__in] => Array
                    (
                    )
    
                [post__not_in] => Array
                    (
                    )
    
                [post_name__in] => Array
                    (
                    )
    
                [tag__in] => Array
                    (
                    )
    
                [tag__not_in] => Array
                    (
                    )
    
                [tag__and] => Array
                    (
                    )
    
                [tag_slug__in] => Array
                    (
                    )
    
                [tag_slug__and] => Array
                    (
                    )
    
                [post_parent__in] => Array
                    (
                    )
    
                [post_parent__not_in] => Array
                    (
                    )
    
                [author__in] => Array
                    (
                    )
    
                [author__not_in] => Array
                    (
                    )
    
                [name] => test-lp-elementor
                [ignore_sticky_posts] => 
                [suppress_filters] => 
                [cache_results] => 1
                [update_post_term_cache] => 1
                [lazy_load_term_meta] => 1
                [update_post_meta_cache] => 1
                [posts_per_page] => 12
                [nopaging] => 
                [comments_per_page] => 50
                [order] => DESC
            )
    
        [redirect_url] => -
        [redirect_type] => native_redirect
        [queried_object] => WP_Post Object
            (
                [ID] => 52892
                [post_author] => 4
                [post_date] => 2022-06-02 15:56:40
                [post_date_gmt] => 2022-06-02 15:56:40
                [post_content] => <style>/*! elementor - v3.6.5 - 27-04-2022 */
    .elementor-heading-title{padding:0;margin:0;line-height:1}.elementor-widget-heading .elementor-heading-title[class*=elementor-size-]>a{color:inherit;font-size:inherit;line-height:inherit}.elementor-widget-heading .elementor-heading-title.elementor-size-small{font-size:15px}.elementor-widget-heading .elementor-heading-title.elementor-size-medium{font-size:19px}.elementor-widget-heading .elementor-heading-title.elementor-size-large{font-size:29px}.elementor-widget-heading .elementor-heading-title.elementor-size-xl{font-size:39px}.elementor-widget-heading .elementor-heading-title.elementor-size-xxl{font-size:59px}</style><h2>Add Your Heading Text Here</h2>
                [post_title] => Test LP Elementor
                [post_excerpt] => 
                [post_status] => publish
                [comment_status] => closed
                [ping_status] => closed
                [post_password] => 
                [post_name] => test-lp-elementor
                [to_ping] => 
                [pinged] => 
                [post_modified] => 2022-06-05 13:48:10
                [post_modified_gmt] => 2022-06-05 13:48:10
                [post_content_filtered] => 
                [post_parent] => 0
                [guid] => https://staging.website.com/?post_type=e-landing-page&p=52892
                [menu_order] => 0
                [post_type] => e-landing-page
                [post_mime_type] => 
                [comment_count] => 0
                [filter] => raw
            )
    
    )
    Thread Starter jigglypuffz

    (@jigglypuffz)

    Any help regarding this issue ?

    Plugin Author Maciej Bis

    (@mbis)

    Hi @jigglypuffz,

    Please accept my apologies for the delay in responding. I am not sure what happened, but I did not get a notification about your response with the debug info.

    If the debug table with data about the redirect was shown after the redirect, this indicates that a third-party plugin was the one that triggered it earlier.

    Could you send me the debug info displayed when “?debug_wp_redirect=1” parameter is added to the landing page URL (the one that is redirected). This should tell us exactly what piece of code triggers the redirect.

    Best regards,
    Maciej

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.