How to set the post_status in template
-
Dears:
I just want to let some post expire after the expiration set in the custom field.
Now I am able to hide it showing from main loop, but all I want to is to set these posts to private instead of hiding them.
How could I write the code in the template?
<?php $expirationtime = get_post_custom_values('expiration'); if (is_array($expirationtime)) { $expirestring = implode($expirationtime); } $secondsbetween = strtotime($expirestring)-time();?> <?php if ( $secondsbetween > 0 ) : ?> <!--=Article here========================================================--> <!--=================================================================--> <?php else : ?> <h2>Expired</h2> <strong><?php wp_transition_post_status('private', '', the_post()); ?></strong> <?php endif; ?> <?php endwhile; ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘How to set the post_status in template’ is closed to new replies.