php - Redirect if a post is in draft status -


i have 2 custom post types called 'project' , 'project-won'. if user goes single 'project' in draft status, want them redirected corresponding 'project-won' post.

each post replicated across both post types, if there 'project' had following url:
mydomain.com/?project=test-project/ , ther 'project-won' url: mydomain.com/?project-won=test-project/.

can put @ top of 'single-project.php' template page such as

<?php if($post->post_status  == "draft"){      //add redirect here 

i don't know best way be?

first of define global variable $post. check if loop.  global $post; if( $post->post_status == 'draft' ) { /* redirect code here */ }  try code may problem solved defining global variable $post. 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -