# Add a Parent Page to Yoast Breadcrumbs for a Post Type

> Puts a regular page in front of a custom post type in the Yoast SEO breadcrumbs, for example Home > Services > Web Design when services have no archive.

- Type: PHP
- Runs: Frontend only
- Category: [Plugin Integrations](https://wpide.com/library/category/integrations/)
- Tags: yoast, breadcrumbs, custom-post-types
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/yoast-breadcrumb-post-type-parent/

## Code

```php
// Post type => ID of the page to show before it.
$wpide_crumb_parents = array(
    'service' => 42,
);

add_filter( 'wpseo_breadcrumb_links', function ( $links ) use ( $wpide_crumb_parents ) {
    if ( ! is_array( $links ) || ! is_singular( array_keys( $wpide_crumb_parents ) ) ) {
        return $links;
    }

    $page_id = (int) $wpide_crumb_parents[ get_post_type() ];

    if ( ! $page_id || 'publish' !== get_post_status( $page_id ) ) {
        return $links;
    }

    array_splice( $links, 1, 0, array( array( 'url' => get_permalink( $page_id ), 'text' => get_the_title( $page_id ), 'id' => $page_id ) ) );

    return $links;
} );
```

## Notes

Map each post type to the ID of the page that should appear as its parent.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Add a Parent Page to Yoast Breadcrumbs for a Post Type" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
