Forum Replies Created
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
October 15, 2019 at 2:45 am in reply to: Including the Parent/Child Custom Post Relationship in Breadcrumbs – Genesis #494005
perlastudio
ParticipantJiveDig,
thanks for help!
This code working:
/********************************** * BREADCRUMB FOR CPT* **********************************/ function cpt_rolety_zewnetrzne_breadcrumb( $crumb, $args ) { // Set register CPT $registerCustomPostType = 'rolety_zewnetrzne'; // Only modify the breadcrumb if in the 'rolety_zewnetrzne' post type if( $registerCustomPostType !== get_post_type() ) return $crumb; $postType = get_post_type_object(get_post_type()); $parentID = wp_get_post_parent_id($post->ID); if($parentID == 0) return $crumb; $parent = get_post($parentID); $link1 = '<span class="breadcrumb-link-wrap"><a class="breadcrumb-link" href="' . get_post_type_archive_link( $registerCustomPostType ) . '"><span class="breadcrumb-link-text-wrap">' . $postType->labels->singular_name . '</span></a></span>'; $link2 = '<span class="breadcrumb-link-wrap"><a class="breadcrumb-link" href="'.get_the_permalink($parent->ID) . '"><span class="breadcrumb-link-text-wrap">'.$parent->post_title.'</span></a></span>'; if(!empty($parent)) { // Build the breadcrumb $crumb = $link1 . $args['sep'] . $link2 . $args['sep'] . get_the_title(); } return $crumb; } add_filter( 'genesis_single_crumb', 'cpt_rolety_zewnetrzne_breadcrumb', 10, 2 );
October 13, 2019 at 5:02 am in reply to: Including the Parent/Child Custom Post Relationship in Breadcrumbs – Genesis #493976perlastudio
ParticipantAnita,
Thanks for article... It was helpful...
I wrote code:
/********************************** * BREADCRUMB * **********************************/ function cpt_rolety_zewnetrzne_breadcrumb( $crumb, $args ) { // Only modify the breadcrumb if in the 'rolety_zewnetrzne' post type if( 'rolety_zewnetrzne' !== get_post_type() ) return $crumb; $parentID = wp_get_post_parent_id($post->ID); if($parentID == 0) return $crumb; $parent = get_post($parentID); if(!empty($parent)) { // Build the breadcrumb $crumb = '<a href="' . get_post_type_archive_link( 'rolety_zewnetrzne' ) . '">Rolety zewnętrzne</a>' . $args['sep'] . '<a href="'.get_the_permalink($parent->ID).'">'.$parent->post_title.'</a>' . $args['sep'] . get_the_title(); } return $crumb; } add_filter( 'genesis_single_crumb', 'cpt_rolety_zewnetrzne_breadcrumb', 10, 2 );
Function working, but links in breadcrumb showing without tag "span" and "class".
Current:
<a href="http://xxx/xxx/xxx/">Link Breadcrumb</a>
Desired:
<span class="breadcrumb-link-wrap"> <a class="breadcrumb-link" href="http://xxx/xxx/xxx/"> <span class="breadcrumb-link-text-wrap">Link Breadcrumb</span> </a> </span>
how to fix it?
Thanks for help.
Best regards,
Tomasz Perliński -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)