wordpress logout redirect to home

Step 1: Go to your WordPress dashboard. Step 2: Click on "Appearance" in the left-hand menu. Step 3: Select "Editor" from the submenu under "Appearance." Step 4: On the right-hand side, open the "Theme Functions" file. Step 5: Insert the following code at the end of the file:

function custom_logout_redirect() {
    wp_redirect(home_url());
    exit();
}
add_action('wp_logout','custom_logout_redirect');

Step 6: Click the "Update" button to save the changes.