Skip to content

feat: add breadcrumbs ancestors for custom post types#33

Merged
laravdiemen merged 1 commit into
mainfrom
feat/add-breadcrumbs-ancestors-custom-post-type
Apr 14, 2026
Merged

feat: add breadcrumbs ancestors for custom post types#33
laravdiemen merged 1 commit into
mainfrom
feat/add-breadcrumbs-ancestors-custom-post-type

Conversation

@laravdiemen

Copy link
Copy Markdown
Contributor

Als je een hiërarchisch custom post type hebt, dan werden die niet getoond in de breadcrumbs.

In onderstaande screenshot miste dus eerst "Talentontwikkeling"
image

Copilot AI review requested due to automatic review settings March 31, 2026 14:00
@laravdiemen laravdiemen requested a review from a team as a code owner March 31, 2026 14:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds breadcrumb ancestor support for hierarchical custom post types so parent items appear in the breadcrumb trail (e.g., missing “Talentontwikkeling”).

Changes:

  • Refactors page-ancestor collection into a reusable getAncestors() helper.
  • Adds fetching + rendering of ancestors for hierarchical custom post types in breadcrumbs.
  • Introduces a mapped ancestor structure (id, label, url) used by add().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +290 to +297
return collect(
get_ancestors($postId, $postType)
)->reverse()
->map(fn (int $id) => [
'id' => $id,
'label' => get_the_title($id),
'url' => get_permalink($id),
]);

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_ancestors() may return IDs as strings. The callback is typed as fn (int $id), which can throw a TypeError if strict typing is in effect and a string is passed. Consider removing the scalar type from the closure parameter and/or casting inside (e.g., $id = (int) $id).

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Als ik de documentatie (https://developer.wordpress.org/reference/functions/get_ancestors/) moet geloven, dan is de return: int[] An array of IDs of ancestors from lowest to highest in the hierarchy.

Comment thread src/Components/Breadcrumb/Crumb.php Outdated
@github-actions

github-actions Bot commented Mar 31, 2026

Copy link
Copy Markdown

Coverage report for commit: 9a4a68d
File: coverage.xml

Cover ┌─────────────────────────┐ Freq.
   0% │ ███████████████████████ │ 100.0%
  10% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  20% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  30% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  40% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  50% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  60% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  70% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  80% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  90% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
 100% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
      └─────────────────────────┘
 *Legend:* █ = Current Distribution 
Summary - Lines: - | Methods: -
FilesLinesMethodsBranches
src/Components
   Accordion.php--100.00%
   BackButton.php--100.00%
   Breadcrumb.php--100.00%
   Dialog.php--100.00%
   FeedbackForm.php--100.00%
   ImgFocalPoint.php--100.00%
   PatternContent.php--100.00%
   ReadSpeaker.php--100.00%
   SocialIcon.php--100.00%
src/Components/Breadcrumb
   Crumb.php--100.00%
src
   ComponentsServiceProvider.php--100.00%
src/Hooks
   PatternContent.php--100.00%
   ReadSpeaker.php--100.00%

🤖 comment via lucassabreu/comment-coverage-clover

@SimonvanWijhe

Copy link
Copy Markdown
Member

Is hiermee de breadcrumb voor Evenementen/Evenementen-Reeksen ook opgelost?

@laravdiemen

Copy link
Copy Markdown
Contributor Author

Is hiermee de breadcrumb voor Evenementen/Evenementen-Reeksen ook opgelost?

Nee, dat is volgens mij nog steeds zo'n geval apart. Ik heb het nu zo opgelost (ik weet niet of dat het mooiste is)

<x-brave-breadcrumb :items="collect([
    ['id' => null, 'url' => home_url(), 'label' => 'Home'],
    ['id' => null, 'url' => home_url('agenda'), 'label' => 'Agenda'],
    ['id' => $postData->id(), 'url' => '', 'label' => $postData->title()],
])" />

@laravdiemen laravdiemen force-pushed the feat/add-breadcrumbs-ancestors-custom-post-type branch from f02eea0 to 9a4a68d Compare April 13, 2026 09:34
@laravdiemen laravdiemen merged commit 9d17e45 into main Apr 14, 2026
5 checks passed
@laravdiemen laravdiemen deleted the feat/add-breadcrumbs-ancestors-custom-post-type branch April 14, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants