Each of our posts are reviews for individual games and we occasionally have to 'pause' the game by changing it from published to pending review. The problem is if the page is indexed by search engines, anyone trying to visit the link will get a 404, which is obviously not desired. I'd like to instead redirect to a listing of all our games.

I can think of a few options but I'm not sure which would be preferred.

I could just do a temporary 302 redirect from that post to the game listing page. I'm not entirely sure how this will work for SEO however.

I could also do a check to see if the post is pending review (in the 404 page?), and if it is, then display the game listing page. I'm not entirely sure how to go about this. I tried finding a function to check if it's in pending review but didn't have any luck.

  • Wouldn't a better solution be to find some way to indicate game pause than by unpublishing the post? For example: why not have a custom post type for "in progress" games, that can be updated continually as the game is played. Then, once the game is finished, post the actual review. Feb 1 '12 at 21:05

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
  • This actually worked for me. Thanks! I'll vote it up once I have 15 reputation points.
    – Kyle
    Feb 1 '12 at 23:17
  • Glad it worked for you! :)
    – Jared
    Feb 2 '12 at 0:42

Sometimes it might be easier to use get_post_status() instead. Example:

if( get_post_status() == 'pending' ) {
  // do stuff

Docs for the get_post_status( $ID ) function ($ID is optional and defaults to the current post ID): https://codex.wordpress.org/Function_Reference/get_post_status

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.