Please consider adding the following code to your plugin to use your plugin’s settings to modify the Yoast SEO breadcrumbs.
add_filter( 'wpseo_breadcrumb_links', function ( $links ) {
$custom_post_type_parents_options = get_option( 'custom_post_type_parents_options' );
if ( !empty( $custom_post_type_parents_options ) ) {
foreach( $custom_post_type_parents_options as $option_name => $value ) {
if ( !empty( $value ) ) {
$post_type = str_replace( 'parent-', '', $option_name );
if ( is_singular( $post_type ) ) {
// Add your landing page as the parent link
$landing_page_id = $value;
$landing_page = get_post( $landing_page_id );
$breadcrumbs = [];
if ( $landing_page->post_parent ) {
$parent = get_post( $landing_page->post_parent );
$breadcrumbs[] = [
'url' => get_permalink( $parent),
'text' => $parent->post_title
];
}
$breadcrumbs[] = [
'url' => get_permalink( $landing_page_id ),
'text' => $landing_page->post_title,
];
array_splice( $links, 1, 0, $breadcrumbs );
}
}
}
}
return $links;
});
]]>
Hi
I am converting my pages using your excellent plugin. My question is I have the page attributes working ok but it doesn’t show the parents from normal pages only the previous/other pages in the custom post type.
Hope that makes sense.
Thanks
Danny
]]>I’m using Breadcrumb NavXT to build my breadcrumbs and I have posts that need to have parent pages so that they have a breadcrumb trail that fits the site’s information architecture.
Well that’s exactly what this plugin does. But I installed it, set the ‘Parent’ for my Posts, then used Breadcrumb NavXT to use the ‘Page parent’ hierarchy for Post breadcrumbs and… nothing. Same path-less breadcrumb trail as before.
I know everyone and their uncle (and their uncle’s theme) has a different way of implementing breadcrumbs. But it would be really great if this plugin could allow site builders to create breadcrumb trails that conform to their site’s information architecture, rather than its actual structure.
…but Breadcrumb NavXT has 900,000 downloads. I have to imagine making this plugin work with it would help a lot of people.
]]>The has_assigned_parent function returns true for types that are assigned to “None”.
The option array is
Array
(
[parent-post] =>
[parent-page] =>
[parent-attachment] =>
)
however, the check
if (! isset( $this->options[ 'parent-' . $post_type ] ) ||
'none' == $this->options[ 'parent-' . $post_type ])
{
return false;
}
won’t ever pass as isset returns true for an empty value, and the value isn’t set to None on the option page.
I think the check should be reversed, to only return true if the conditions are met (the statement seems backwards IMHO).
I’ve put empty($this->options[ 'parent-' . $post_type ])
after line 272 of custom-post-type-parents.php to temporarily correct this.
Hi after desactivating and reacitvatin does not work anymore Need some help with this.
THX Roman
Hi Mickey!
Thanks for a great plugin! It’s really a pain saver.
I was wondering if it’s possible to make it work together with WPML? The parent page will be different depending on the language on this site I’m working on.
Thanks!
// Stefan
Good Morning,
my Problem ist that the Old Parent Page (Blog) is not removed and currently my Menu shows the new and old highlighted.
Is this an Bug or an feature?
Thank you!
]]>This plugin is breaking in version 4.3.1, It seems to have something to do with the way that it is integrated with the Simple Section Navigation widget. This plugin would have been able to give me exactly the functionality i needed for my site, would you be able to update it? Thank you.
]]>i have 3 custom post types, but only one shows up on the plugin’s settings page
https://note.io/1xwO4JX
which means that i can only set the parent page for one custom post type.
]]>