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
- Slug of a child page is accessible with and without the parent slug in the URL
- Show more than 20 items in pages or posts edit dashboard
- How to display last 3 posts (recent posts) in a static page?
- How to load javascript on custom page template?
- Change page template programmatically ?
- Conditional tag to check if ‘page.php’ is being used?
- Get top level page parent title
- Editing Complex Pages in Visual Mode
- Link section within page with slash (/) and not hash (#) without reloading the page
- Creating a template using a specific slug name, for a page with a parent page
- WordPress admin screen very slow / timing out when editing or adding a new page/custom post
- Is there a default template file for child pages / subpages?
- Users are redirected to homepage instead of wp-admin
- Multiple areas of dynamic content in a page
- How to create virtual pages with information from user meta profile fields?
- Private pages that work when you are not logged into WP admin
- Add custom admin menu item for pages using a certain template
- Display latest comments on page with pagination
- How to add pages to feed?
- Woocommerce Login Redirect not working [closed]
- PHP If user is logged in & on home page redirect
- Relative instead of absolute links in pages?
- Produce a plain page with only a message
- Password Protected Page Title
- Redirect to Current Page after Login
- Login redirect problem
- Page displays content from different query?
- Making audio playlist by getting page’s parent’s ID
- Pages Column Sorting WordPress Version 3.0.3
- More Fields Required For Password protect page