Note: Recent versions of Elementor now let you configure where the “Exit to Dashboard” button goes. Looks like someone on the Elementor dev team read this article!
OVERVIEW
One of the most frustrating things about Elementor’s page builder interface is the way the Exit to Dashboard works. When you click on “Exit to Dashboard” you end up in the WordPress Gutenberg Block Editor instead of the WordPress Dashboard, as promised. Users may panic when they are dumped into the WordPress Editor only to see page with no content.
Even worse, if they try to use the WordPress Editor, they will damage the Elementor generated content if they save their changes. The expected behavior when clicking the button is to land on the WordPress Dahboard screen. Landing on the Pages or Posts list might make more sense. This would allow the user to start working on another page or post.
As it turns out, this is pretty simple to fix. Why Elementor continues to behave this way is incomprehensible.
This article will show you how to fix the behavior of the “Exit to Dashboard” button with just a few lines of code. Additional code examples will show you how to redirect the button to a list of posts, instead of the dashboard.
HOW TO FIX ELEMENTOR’S “EXIT TO DASHBOARD” BUTTON
Elementor provides a WordPress Filter Hook that allows you to change the link associated with the “Exit to Dashboard” button. You can use the get_admin_url( ) WordPress function to get the Dashboard URL, then return it to the ‘elementor/document/urls/exit_to_dashboard’ filter. To change the button’s link, add the following code to your theme’s functions.php file.
add_action( 'init', function () {
/**
* Fix 'Exit to Dashboard' button in Elementor.
*/
add_filter( 'elementor/document/urls/exit_to_dashboard', function ( $url, $doc ) {
return get_admin_url();
}, 10, 2 );
} );
EXIT TO POST OR PAGE LIST
It is probably more useful to exit Elementor to the “All Posts” or “All Pages” list, depending on the current document type. This requires a little more coding. First, we need to determine the post type for the current document. Then we can build the link to the correct list page for that post type. To do this, add the following code to your theme’s functions.php file.
add_action( 'init', function () {
/**
* Fix 'Exit to Dashboard' button in Elementor.
*/
add_filter( 'elementor/document/urls/exit_to_dashboard', function ( $url, $doc ) {
/**
* Get post type for the current Elementor document.
*/
$post_type = $doc->get_post()->post_type;
/**
* Build a link back to the page or post list, depending on current document.
* Default to the Dashboard link if post type is not recognized.
*/
if ( in_array( $post_type, [ 'post', 'page' ] ) ) {
$url = get_admin_url( null, 'edit.php?post_type=' . $post_type );
} else {
$url = get_admin_url();
}
return $url;
}, 10, 2 );
} );
EXIT TO A POST LIST FOR THE CURRENT POST TYPE
If your theme uses Custom Post Types, you can add a bit more code to build an exit button that leads to that post type’s list. Before building the link, first verify that the post type has a valid edit link. If it does not, then simply return the Dashboard link. To do this, add the following code to your theme’s functions.php file.
add_action( 'init', function () {
/**
* Fix 'Exit to Dashboard' button in Elementor.
*/
add_filter( 'elementor/document/urls/exit_to_dashboard', function ( $url, $doc ) {
/**
* Get post type info for the current Elementor document.
*/
$post_type = $doc->get_post()->post_type;
$post_type_obj = get_post_type_object( $post_type );
/**
* Build a link to the list of all post types.
* Default to the Dashboard link if something is missing.
*/
if ( !$post_type_obj || empty( $post_type_obj->_edit_link ) ) {
$url = get_admin_url();
} else {
$url = get_admin_url( null, 'edit.php?post_type=' . sanitize_key( $post_type ) );
}
return $url;
}, 10, 2 );
} );
Share the post "Fix Elementor’s “Exit to Dashboard” button"