post_status is part of the $post object which you can use to determine if it is published, a draft, pending, etc.
if( $post->post_status == 'pending' )
// do stuff
Related Posts:
- How to force a 404 on WordPress
- Redirect Restricted Page to 404
- How to prevent automatic redirection of 404 errors and “incorrect” URLs?
- How do I skip wordpress’s 404 handling and redirect all 404 errors for static files to 404.html?
- How do I programmatically generate a 404?
- How do I skip wordpress’s 404 handling?
- 404 redirection and Google’s index [closed]
- Redirect feed to 404 page
- Why specific file directory fails to redirect but its parent folder succeeds?
- WordPress blocking/preventing viewing of .cgi file in subdirectory [closed]
- Deny access to a path (give 403 or 404 response)
- Redirect a page id url but not the page slug
- Defining a custom 404 for non-WordPress parts of site
- WordPress Auto-Redirecting on 404
- Built-In Postname Redirection vs Hard Redirects in relation to SEO and performance
- How to redirect a wrong search on my wordpress website to the error 404 page?
- WP page 404 error only on mobile
- Force 404 redirect to home?
- How can I redirect users on the new 404 page without plugin?
- How to redirect an old page url to the homepage
- Dynamic 404 page content while still keeping 404 status code?
- Redirect to home if page doesn’t exists [duplicate]
- Redirect to parent page if child does not exist
- How to redirect non existent pages/posts in wordpress using htaccess
- How to Redirect WordPress domain.com/?anyword to 404 Page?
- How do I redirect the browser to 404 page, if no posts are found in home page
- How do i make WordPress return 404 instead of redirecting on misspelled page?
- How to redirect if 404 error in wordpress then redirect 404.php url
- Redirect to /404/
- Page editing in backend redirecting to 404 page not found with url /post.php
- How do I skip wordpress’s 404 handling?
- Subpages return 404 server error
- WordPress subfolders htaccess bypassing the root htaccess RewriteRule
- Why my htacess rewrite return 404?
- How to Redirect Url to homepage?
- Stopping media file redirects
- Forcing header cache control in 404 pages
- redirect to 404 page
- Redirect certain 404 pages to parent page
- Redirect of specific words in URL ahead of website migration
- Disable front end to use as CMS only?
- Redirect Localhost wordpress site to dashboard
- Why is wp_redirect() preferable to a standard PHP header redirect?
- How to redirect a sucessful registration to a page template?
- How to redirect all requests to wp-login.php?
- WordPress overriding actual subdirectories
- Redirect to “All Posts” after post update or publish in Block Editor
- Redirect user after login/registration globally
- how to do logout redirect to current url
- Moving variables from one page to another
- Custom Registration page – prevent redirect to wp-login.php?action=register
- https redirect (with .htaccess) redirect loop
- homepage redirects to login page when user session expires
- Redirect blog archive into certain format
- How to publish new posts/pages in root instead of subfolder, but keep old structure in place?
- forward domain name to particular page?
- Contact Form 7 Data to Whatsapp Link
- Custom Permalink
- How can I replace my primary url globally with a parked one?
- I need to redirect an entire subdirectory in WordPress to the homepage – is this correct?
- My website on checking showing 403 error on HTTP Status [closed]
- I get redirected too many times only in wp-admin?
- How do I determine what is causing a redirect for a given page?
- Trouble running local WordPress in Google App Engine
- Empty folder being created by WordPress, breaks site
- User redirect to specific URL after logging in
- What is the most efficient (ie. less server intensive) way for 301 redirects?
- Logout without confirmation and SAME window on mobile
- adding GET variables to a header() location in a page template
- WordPress CSS/Theme gone after SSL got activated
- Redirect 301 of old urls to wordpress urls
- How can I redirect a request to the site root using htaccess, if there’s not a specific cookie set?
- redirect “about author” code to about page
- get_bloginfo prints IP instead of url
- How to redirect all page requests to a single “goodbye” homepage? [duplicate]
- redirect second domain to static page
- Endless Redirects Suddenly Disable Site
- Redirecting home to /wp-login.php?action=register
- Redirect to custom login page if not logged in and redirect to home if logged in user try to login, how?
- Erase the HTML website and replace it with a WordPress website -301 Redirection
- How to replace the links http to https
- Redirect only PDFs in different folders?
- How to redirect?
- How to disable WordPress URL autocomplete / recognition?
- Redirect user on login using extra field value on login form
- Cannot get 301 redirection in htaccess to work (either Redirect or Rewrite)
- Redirect to Page after Login (with variable)
- I have cloudflare flexible enabled, How to redirect to https for Nginx server
- Redirecting page 1 to default permalink
- Redirect problem: How to redirect to the original URL after login
- Login Form Redirection
- WordPress HTTPS – ‘… better to use HTTP for installation …’
- Hosting the WordPress website on someone else’s web URL
- WordPress Logout Redirect Follow up
- Simple function not working on frontend and can’t figure a way to debug it
- After migration index page still redirects to old url
- Redirect to File attached to a Post using ACF
- Redirect WordPress multilingual website to the domain
- How to prevent wordpress from redirecting media attachment page to media page?
- How can I do automatic redirects to canonical URLs as defined by Yoast SEO?