diff --git a/wagtail/admin/templates/wagtailadmin/pages/listing/_page_title_cell.html b/wagtail/admin/templates/wagtailadmin/pages/listing/_page_title_cell.html
index c88f6ff8fe..075f92a96f 100644
--- a/wagtail/admin/templates/wagtailadmin/pages/listing/_page_title_cell.html
+++ b/wagtail/admin/templates/wagtailadmin/pages/listing/_page_title_cell.html
@@ -1,4 +1,9 @@
{% load l10n %}
{% include "wagtailadmin/pages/listing/_page_title_explore.html" with page=instance show_locale_labels=show_locale_labels %}
+ {% if parent_page %}
+
+ {% endif %}
|
diff --git a/wagtail/admin/tests/pages/test_explorer_view.py b/wagtail/admin/tests/pages/test_explorer_view.py
index 4ce38eed91..dc661aeb70 100644
--- a/wagtail/admin/tests/pages/test_explorer_view.py
+++ b/wagtail/admin/tests/pages/test_explorer_view.py
@@ -422,6 +422,12 @@ class TestPageExplorer(WagtailTestUtils, TestCase):
self.assertEqual(response.status_code, 200)
page_ids = [page.id for page in response.context["pages"]]
self.assertEqual(page_ids, [self.old_page.id])
+ # Results that are not immediate children of the current page should show their parent
+ self.assertContains(
+ response,
+ 'Welcome to your new Wagtail site!',
+ html=True,
+ )
# search results should not include pages outside parent_page's descendants
response = self.client.get(
diff --git a/wagtail/admin/ui/tables/pages.py b/wagtail/admin/ui/tables/pages.py
index 262eddd5f1..1ed46ea0be 100644
--- a/wagtail/admin/ui/tables/pages.py
+++ b/wagtail/admin/ui/tables/pages.py
@@ -24,6 +24,7 @@ class PageTitleColumn(BaseColumn):
context["page_perms"] = instance.permissions_for_user(
parent_context["request"].user
)
+ context["parent_page"] = getattr(instance, "annotated_parent_page", None)
context["show_locale_labels"] = parent_context.get("show_locale_labels")
context["perms"] = parent_context.get("perms")
return context
diff --git a/wagtail/admin/views/pages/listing.py b/wagtail/admin/views/pages/listing.py
index b4b24e39bf..02c7005983 100644
--- a/wagtail/admin/views/pages/listing.py
+++ b/wagtail/admin/views/pages/listing.py
@@ -250,6 +250,21 @@ class BaseIndexView(PermissionCheckedMixin, BaseListingView):
context = super().get_context_data(**kwargs)
+ if self.is_searching:
+ # postprocess this page of results to annotate each result with its parent page
+ parent_page_paths = {
+ page.path[: -page.steplen] for page in context["object_list"]
+ }
+ parent_pages_by_path = {
+ page.path: page
+ for page in Page.objects.filter(path__in=parent_page_paths).specific()
+ }
+ for page in context["object_list"]:
+ parent_page = parent_pages_by_path.get(page.path[: -page.steplen])
+ # add annotation if parent page is found and is not the currently viewed parent
+ if parent_page and parent_page != self.parent_page:
+ page.annotated_parent_page = parent_page
+
context.update(
{
"parent_page": self.parent_page,