Forums

How to set the post_status in template (4 posts)

  1. gaoyuan
    Member
    Posted 3 years ago #

    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; ?>
  2. gaoyuan
    Member
    Posted 3 years ago #

    is it like this? But it does not work!

    <?php wp_transition_post_status('private', '', the_post()); ?>

  3. gaoyuan
    Member
    Posted 3 years ago #

    anyone could do me a favour?

  4. gaoyuan
    Member
    Posted 3 years ago #

    Need your help

Topic Closed

This topic has been closed to new replies.

About this Topic