For your if condition, use the is_admin function to determine if the user is currently viewing a backend administrative dashboard page or are on the frontend of the site.
So your code above would resemble:
add_action('wp_logout','redirect_after_logout');
function redirect_after_logout(){
if( is_admin() ) {
wp_redirect( home_url() );
exit();
}
}
For more information, see the codex documentation at https://codex.wordpress.org/Function_Reference/is_admin
Related Posts:
- How to change redirect after moving a page to trash?
- WordPress redirects to login page when I enter url.com/index.php
- Check if wp-login is current page
- Check IF is a “single product page” and Check the “role” for a Redirect
- How to redirect on particular page in wordpress? [closed]
- Can I display the widget admin in the page admin?
- Change admin startpage to Pages-page?
- Only allow new subpages to be created
- Is there a way to remove or hide individual pages on the Edit Pages screen?
- Where does the 404 redirection happen?
- Associate Page with User
- How to disable Page Attributes dropdown in wp-admin
- Dashboard–> All Pages “How to create folders?”
- How to make certain page templates visible to admin only
- Password Protected Page Not Displaying Content After Entering Password
- Change the Default Pages Menu View in wp-admin
- Redirect “Sorry, you are not allowed to access this page.” to Home
- Add a Menu Link (to a WordPress Page) in the Admin Menu/Sidebar
- How to redirect a page to subdomain?
- Remove pages from backend list *and* update counter accordingly
- Slug is redirecting to 404
- Edit page’s “Restore the backup” link does nothing
- How to redirect login and register pages
- If a page does not exist, include a different page?
- Missing ‘Page Attributes’ in page edit
- How to redirect a page to another?
- Admin pages, edit notes of the title of posts and pages
- Can’t locate a hidden private page
- WordPress Admin Login Redirect Problem
- Role – edit page but not publish
- Page redirects to archive
- Unique page URL redirect to file_get_contents() at domain
- Adding Page URL to the Pages Admin Table
- Could be a namespace conflict (?) with login form and register form on the same page
- Change base URL of pages created by certain users
- Redirect page to default subpage
- How to use is_admin in page content?
- Edit page shown after login in WordPress?
- Can’t login to my admin area
- Bad pages redirection
- Page access only from a specific page in wordpress website
- Change page name in admin list
- Logout Redirect and also WP-login.php Redirect
- WordPress page not taking precedence over server directory
- Is it possible to restrict access to specific pages in the admin area based on the page slug?
- get_permalink not fetching correct pages
- Folder wordpress page redirect
- How to rewrite a page url
- 404.php only works if I’m logged in. Everybody else redirects to wp-login.php – why?
- redirect index.html inside folder to wordpress page of same name
- Custom page only editable by one user
- Publish page by invoking submit via jQuery
- How should I set up a Tumblr blog at a WordPress Page?
- accessing the Admin page
- remove “Edit” from select pages
- URL redirect to home page issue in word press site
- Trying to login to my site redirects me to the first page
- Cannot use old slug – it just 301s to site home page
- Make wordpress pages accessible for Woocommerce logged in users only
- Post id(login page) not found
- Adding CSS styles to Admin Area PAGES only (not POSTS or CPT)
- Group Pages based on Parent in Admin Area
- disable trashability for certain pages
- Custom admin menu for a selection of pages
- Pages redirect me to the homepage
- How to access variables from one plugin in another
- How can a user login on a wordpress page?
- How to change the default location where new post gets stored?
- How to make a secondary Pages Screen
- Remove element from admin page editing part
- how to update page without reloading the page builder?
- Slug of a child page is accessible with and without the parent slug in the URL
- Loading ACF Field content on a 404.php page
- Why can’t pages be categorized / tagged?
- Set different heights per screen size with inline styles CSS into the ‘Text’ section of a Page
- Add custom action to the page listing screen
- Adding in additional pages into a custom theme
- Login to admin by frontend form?
- My edits are not saved
- How to list pages from an author?
- Editing Pages Icons Are Not Showing Up – Why is this happening?
- How to sorted Parent Page in WP-admin
- WordPress Admin login redirect to homepage
- Display meta data attribute in user profile
- Add the same content to multiple pages
- wp_list_pages get the hole hierarchy for current page
- Pages in wp-admin is not found 404
- Shortcode runs when editing page
- how can i display children of my parent page in one of the children page (wordpress)
- Cannot Create A Page or Post in WordPress 5.2.1
- My English homepage will not update
- How to redirect user to Referrer Page using wp_signon in Custom Login Page in WordPress
- How to select what posts goes into which custom page template?
- WordPress default theme cannot get full page on entry content div
- Displaying all pages which comes under a category id
- Some pages can’t be updated – post_content field not updating
- How to filter page title for certain page?
- Can I use the wordpress loop in pages?
- Add addtional page parameter before loading the page