feat: add breadcrumbs ancestors for custom post types#33
Conversation
There was a problem hiding this comment.
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 byadd().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return collect( | ||
| get_ancestors($postId, $postType) | ||
| )->reverse() | ||
| ->map(fn (int $id) => [ | ||
| 'id' => $id, | ||
| 'label' => get_the_title($id), | ||
| 'url' => get_permalink($id), | ||
| ]); |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
|
Coverage report for commit: 9a4a68d Summary - Lines: - | Methods: -
🤖 comment via lucassabreu/comment-coverage-clover |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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) |
f02eea0 to
9a4a68d
Compare
Als je een hiërarchisch custom post type hebt, dan werden die niet getoond in de breadcrumbs.
In onderstaande screenshot miste dus eerst "Talentontwikkeling"
