{"id":122146,"date":"2013-10-02T11:30:57","date_gmt":"2013-10-02T15:30:57","guid":{"rendered":"http:\/\/wpmu.org\/?p=122146"},"modified":"2022-03-30T01:23:11","modified_gmt":"2022-03-30T01:23:11","slug":"how-to-archive-wordpress-posts-and-pages","status":"publish","type":"post","link":"https:\/\/wpmudev.com\/blog\/how-to-archive-wordpress-posts-and-pages\/","title":{"rendered":"How To Archive WordPress Posts and Pages"},"content":{"rendered":"<p>What do you do with published WordPress content that you want to remove from public view but don&#8217;t want to trash?<\/p>\n<p>You archive it. Simple. Well, no. Functionality that arguably should either be built-in or definitely should be easy to implement is actually unnecessarily difficult. It also doesn&#8217;t help that WordPress muddies the waters by using the archive term for older posts.<\/p>\n<p>In this article, I&#8217;ll show you how you can archive content using the <a title=\"Edit Flow\" href=\"http:\/\/editflow.org\/\" rel=\"noopener\" target=\"_blank\">Edit Flow plugin<\/a> to do the heavy lifting.<\/p>\n<ul>\n<li><a href=\"#status\">What&#8217;s Your Status?<\/a><\/li>\n<li><a href=\"#install\">Install the Edit Flow Plugin<\/a><\/li>\n<li><a href=\"#modules\">Switch Off Unused Modules<\/a><\/li>\n<li><a href=\"#statuses\">Configure the Statuses<\/a><\/li>\n<li><a href=\"#menus\">But What About Menus?<\/a><\/li>\n<\/ul>\n<figure id=\"attachment_122180\" class=\"wp-caption aligncenter\" data-caption=\"true\"><a rel=\"lightbox[122146]\" class=\"blog-thumbnail\" href=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2013\/09\/AWI-core-archive_hg.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"size-ratio-large wp-image-122180\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2013\/09\/AWI-core-archive_hg-700x261.jpg\" alt=\"Photo of an archive\" width=\"700\" height=\"261\" \/><\/a><figcaption class=\"wp-caption-text\">Archiving is an important but missing part of WordPress<\/figcaption><\/figure>\n<p><em>Note: The approach described in this article applies to posts, pages and custom post types. I&#8217;ve used the term &#8220;post&#8221; simply for convenience.<\/em><\/p>\n<h2 id=\"status\">What&#8217;s Your Status?<\/h2>\n<p>To provide archiving, we need to add another step to the end of the publishing process, an option after &#8220;published&#8221;, by adding a new post status of &#8220;archived&#8221;. Archiving posts is then a simple matter of changing the post status to the new status and ensuring that the archived post does not appear anywhere on the site, including in search results and menus.<\/p>\n<p>WordPress has eight built-in post statuses and adding to the list is very easy. However, simple tasks such as adding the new status to the post status drop-down in the Publish meta box on the post edit screen is frustratingly difficult. With no helpful filter or action available within\u00a0WordPress itself, the most common solution uses JQuery-assisted HTML acrobatics to force new statuses into the user interface in the browser. Not exactly development best practice.<\/p>\n<p>Fortunately, the Edit Flow plugin can help us extend the publishing workflow whilst avoiding client-side HTML wrangling.<\/p>\n<h2 id=\"install\">Install the Edit Flow Plugin<\/h2>\n<p><a title=\"Learn more about Edit Flow \" href=\"http:\/\/editflow.org\/\" rel=\"noopener\" target=\"_blank\">Edit Flow<\/a> has plenty of great features for managing posts in a team environment. We won&#8217;t go into them here but I&#8217;d recommend reading <a title=\"Edit Flow Keeps Your WordPress Approval Workflow Together\" href=\"https:\/\/wpmudev.com\/blog\/edit-flow-keeps-your-wordpress-approval-workflow-together\/\" target=\"_blank\">Paul Kaiser&#8217;s review of Edit Flow<\/a> here on WPMU.org.<\/p>\n<h2 id=\"modules\">Switch Off Unused Modules<\/h2>\n<p>For now, we just need to have Edit Flow&#8217;s Custom Statuses module enabled, so once installed, click on Edit Flow in the main menu and disable all modules except for Custom Statuses.<\/p>\n<div class=\"image-grid cgrid-row\">\n<div class=\"cgrid-col cgrid-col-span-full\">\n<figure id=\"attachment_207715\" class=\"wp-caption aligncenter\" data-caption=\"true\"><a rel=\"lightbox[122146]\" class=\"blog-thumbnail\" href=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2013\/10\/edit-flow-custom-statuses.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-207715 size-full\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2013\/10\/edit-flow-custom-statuses.png\" alt=\"Edit Flow modules management screen.\" width=\"600\" height=\"320\" \/><\/a><figcaption class=\"wp-caption-text\">For archiving you only need Custom Statuses but check out the other modules too.<\/figcaption><\/figure>\n<\/div>\n<\/div>\n<h2 id=\"statuses\">Configure the Statuses<\/h2>\n<p>Click on Custom Statuses and,<\/p>\n<ol>\n<li>Make the\u00a0Draft\u00a0status the default status by hovering your mouse over &#8220;Draft&#8221; and clicking on the &#8220;Make Default&#8221; menu option.<\/li>\n<li>Delete all the statuses except for Draft (again, roll your mouse over the status and click on the <em>Delete<\/em> menu option).<\/li>\n<li>Use the &#8220;Add New&#8221; form to add a new custom status of &#8220;Archived&#8221;. Click on the &#8220;Options&#8221; tab and select the post types that you want to be able to archive &#8211; custom post types are available as well.<\/li>\n<\/ol>\n<p>Now, in the Publish meta box on the post edit screen, the Status drop down will show the Custom Statuses, including the new Archived status.<\/p>\n<figure id=\"attachment_207717\" class=\"wp-caption aligncenter\" data-caption=\"true\"><a rel=\"lightbox[122146]\" class=\"blog-thumbnail\" href=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2013\/10\/archived-status.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-207717\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2013\/10\/archived-status.png\" alt=\"Updated Status dropdown.\" width=\"600\" height=\"500\" \/><\/a><figcaption class=\"wp-caption-text\">The updated Status dropdown.<\/figcaption><\/figure>\n<p>To archive a post, simply select &#8220;Archived&#8221; and click on &#8220;Update&#8221;. This will remove the post from the front-end, including searches. You&#8217;ll also see that an &#8220;Archived&#8221; link, complete with post count, is added to the status links at the top of the post list page, giving you quick and easy access to the archived posts.<\/p>\n<figure id=\"attachment_207718\" class=\"wp-caption aligncenter\" data-caption=\"true\"><a rel=\"lightbox[122146]\" class=\"blog-thumbnail\" href=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2013\/10\/archived-menu.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-207718 size-full\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2013\/10\/archived-menu.png\" alt=\"Screen grab showing Archived in the post status links on the post listing screen\" width=\"600\" height=\"127\" \/><\/a><figcaption class=\"wp-caption-text\">The new Archived link added to the post list screen<\/figcaption><\/figure>\n<h2 id=\"menus\">But What About Menus?<\/h2>\n<p>WordPress ignores the status when it comes to building menus. If you&#8217;ve put a page in the menu then it will be shown even if its status is archived or, indeed, draft.<\/p>\n<p>To save you having to check your menus every time you archive a page, use this code either in your <em>functions.php<\/em> file or in a simple plugin:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\r\nfunction remove_archived_from_menu($post) {\r\n_wp_delete_post_menu_item($post-&gt;ID);\r\n}\r\nadd_action( &#039;publish_to_archived&#039;, &#039;remove_archived_from_menu&#039;);\r\n\r\n<\/pre>\n<p>This hooks into the status change action that is fired every time a post changes status. In this case we are interested in the change from &#8220;publish&#8221;\u00a0to &#8220;archive&#8221;\u00a0(draft items are unlikely to be in a menu). When that change occurs we want to delete any menu item with the post&#8217;s ID.<\/p>\n<p>Archiving content is a fairly basic function of a content management system and it&#8217;s a little surprising that WordPress doesn&#8217;t already have this facility built-in. Rolling your own solution is cumbersome and the simplest solution is a hack that would not sit well with most developers.<\/p>\n<p>Using Edit Flow to provide archiving is a straight-forward, hack-free solution that not only provides simple archiving functionality but also an introduction to a powerful content management plugin.<\/p>\n<p>Photo credit: <a title=\"Picture source\" rel=\"noopener\" class=\"blog-thumbnail\" href=\"http:\/\/commons.wikimedia.org\/wiki\/File:AWI-core-archive_hg.jpg\" target=\"_blank\">Hannes Grobe<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What do you do with published WordPress content that you want to remove from public view but don&#8217;t want to trash? You archive it. But functionality that should be easy to implement is actually unnecessarily difficult. Luckily Edit Flow provides a solution.<\/p>\n","protected":false},"author":262394,"featured_media":167040,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"blog_reading_time":"","wds_primary_category":0,"wds_primary_tutorials_categories":0,"footnotes":""},"categories":[263],"tags":[10211],"tutorials_categories":[],"class_list":["post-122146","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-admin"],"_links":{"self":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/122146","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/users\/262394"}],"replies":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/comments?post=122146"}],"version-history":[{"count":9,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/122146\/revisions"}],"predecessor-version":[{"id":208244,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/122146\/revisions\/208244"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media\/167040"}],"wp:attachment":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media?parent=122146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/categories?post=122146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tags?post=122146"},{"taxonomy":"tutorials_categories","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tutorials_categories?post=122146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}