Of course there is a Drafts section in Post and Pages, but how would I make an Archive section - which would contain previously published posts and page?
-
Which criteria do you use to check if a post should be in the archives or not? Perhaps you can try using a category if you want to decide it on your own for each post...– SvenCommented May 23, 2013 at 14:57
-
well, the user would change the status to 'published' to 'archived', and then it would not appear to visitors– cannyboyCommented May 23, 2013 at 15:00
2 Answers
You can add a custom post status via register_post_status
, but I'll warn you now that the API only half exists for this. You won't see any UI to allow you to set this status, you'll have to provide your own via a custom meta box, and you won't see anything on the back-end to allow you to filter on this status until you've assigned the status to a post.
It's not quite easy to deal with register_post_status yet, as it's not meant to be used within themes or plugins, but there is a nice plugin called Edit Flow which will do the job. Use the interface within the plugin to register your new post status and it will automatically appear in the dropdown menu beside your post.
You'll get the current status of the blogpost via get_post_status:
<?php
if ( get_post_status ( $ID ) == 'archived' )
{
echo 'archived';
}
else
{
echo 'public';
}
?>