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?
- Require title for pages
- Add a new page to wordpress programmatically
- List all pages and children in separate ul
- How do I load custom scripts and styles for a page?
- WP won’t save changes in post (any)
- Registering multiple sidebars with data from an array
- Extra title output with this function wp_list_pages
- Redirect user to login before viewing custom post
- Related Links Page with moderated, user suggested link submissions
- Adding Author and Updated Schema Markup to WordPress Static Pages
- Trying to Edit a Page but it sends me to a Product Edit page
- How to edit a HTML list in WordPress?
- All Pages visible on the Frontpage
- How do we exclude multiple pages (like opposite of is_page)
- Create page template with some static contents
- Can I schedule my site to launch at a set time and date?
- multiple post into single page
- Does Feedburner send notifications about WordPress pages?
- Ordering Pages and Increasing Navigation
- Show private pages in public when you logged in as admin?
- How to delete the scrollbar in my pages?
- How to filter page title for certain page?
- Not allow add New Page for role ‘editor’
- How do you assign custom template for Posts page (under Front page displays setting)
- Redirect Every Instance of The Author Template Pages to Custom Author Pages
- 1st Level Page with No Children
- Directory location of new page
- Grabbing the_content from “about us”
- Page specific values in widgets
- Woocommerce – Making product pages child of shop
- appearance of new page
- How to read a page’s “Shortcodes” from the Template File?