Skip to content

Commit 89948b5

Browse files
mrleblanc101nlemoine
authored andcommitted
feat: Add post archive link in menu
1 parent 9061105 commit 89948b5

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/Admin/Admin.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,22 @@ public function addAdminBarArchiveLink(WP_Admin_Bar $adminBar): void
236236
*/
237237
public function addPostTypeSubmenus(): void
238238
{
239+
$pageId = get_option('page_for_posts');
240+
$postTypeObject = get_post_type_object('post');
241+
if ($postTypeObject && $pageId) {
242+
$postType = 'post';
243+
$editPostLink = get_edit_post_link($pageId);
244+
$archivesLabel = \is_string($postTypeObject->labels->archives) ? $postTypeObject->labels->archives : $postType;
245+
246+
add_submenu_page(
247+
'edit.php',
248+
$archivesLabel,
249+
$archivesLabel,
250+
'edit_pages',
251+
$editPostLink
252+
);
253+
}
254+
239255
foreach ($this->api->getPageIds() as $postType => $pageId) {
240256
$postTypeObject = get_post_type_object($postType);
241257
if (!$postTypeObject) {

0 commit comments

Comments
 (0)