Redirect all pages to homepage but still allow dashboard

Just use ‘ template_redirect ‘ hook

This action hook executes just before WordPress determines which template page to load. It is a good hook to use if you need to do a redirect with full knowledge of the content that has been queried.

add_action('template_redirect','redirect_all_pages_to_home');

function redirect_all_pages_to_home() {
    if ( ! is_front_page() ) {
        wp_redirect( get_home_url() );
        exit;
    }
}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)