Conditional tag-like function to tell if post is in trash?

admin2025-01-07  5

What could I put in my theme to tell if a post is in the trash or not?

For example:

<?php if (is_trash) echo 'This post is in the trash!' ?>

What could I put in my theme to tell if a post is in the trash or not?

For example:

<?php if (is_trash) echo 'This post is in the trash!' ?>
Share Improve this question edited Apr 26, 2013 at 21:09 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Oct 3, 2011 at 14:30 MTTMTT 3,58612 gold badges47 silver badges74 bronze badges 1
  • 2 Still not solved? Or just abandoned? – fuxia Commented Jul 16, 2012 at 23:25
Add a comment  | 

1 Answer 1

Reset to default 1

You could use get_post_status():

function is_trash( $post_id = 0 )
{
    0 == $post_id and $post_id = get_the_ID();
    return 'trash' === get_post_status( $post_id );
}

Side note: To get a list of all registered post status objects use get_post_stati() – yes, that's wrong.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736252433a45.html

最新回复(0)