Tagged: breadcrumb, breadcrumbs
-
AuthorPosts
-
August 17, 2020 at 8:55 pm #1238616
Hi there,
Using a variety of methods I’ve found in the forums, I’m creating a unique structure for our breadcrumbs.
The intent:
Home > Permanent Page > Custom Page Relationship > This PageI have this set up pretty well, but it’s currently coming out as:
Home > This Page > Permanent Page > Custom Page RelationshipI can’t figure out how to re-order the function so that “This Page” gets placed at the very end.
My function:
add_filter('avia_breadcrumbs_trail', 'avia_adjust_breadcrumb', 50, 1); function avia_adjust_breadcrumb($trail) { if(is_singular( array( 'market', 'service', 'product', 'case_studies' ) )) { $erosion = get_post(113); $custom_breadcrumb_parent = get_field( "custom_breadcrumb" ); $trail[1] = '<a href="' . ( $erosion->post_name ) . '" title="' . esc_attr( $erosion->post_title ) . '">' . esc_attr( $erosion->post_title ) . '</a>'; $trail[2] = '<a href="' . ( $custom_breadcrumb_parent->post_name ) . '" title="' . esc_attr( $custom_breadcrumb_parent->post_title ) . '">' . esc_attr( $custom_breadcrumb_parent->post_title ) . '</a>'; } return $trail; }
- This topic was modified 4 years, 4 months ago by Alex Morrison.
August 20, 2020 at 9:23 pm #1239623Hey Alex,
Could you please create temporary admin logins and post them here privately so we can look into it?
I tried recreating this on my local installation with following code and it worked fine for me
add_filter('avia_breadcrumbs_trail', 'avia_adjust_breadcrumb', 50, 1); function avia_adjust_breadcrumb($trail) { if(is_single) { $erosion = get_post(68); $trail[1] = '<a href="' . ( $erosion->post_name ) . '" title="' . esc_attr( $erosion->post_title ) . '">' . esc_attr( $erosion->post_title ) . '</a>'; $trail[2] = '<a href="#" title="test-title">test title for custom</a>'; } return $trail; }
Please see screenshots in private content field
Best regards,
YigitAugust 20, 2020 at 9:26 pm #1239624Hey there – I just had a breakthrough in figuring out what to do. I had to “unset” the trail_end and reset it to move to the end of the trail:
add_filter('avia_breadcrumbs_trail', 'avia_adjust_breadcrumb', 50, 1); function avia_adjust_breadcrumb($trail) { if(is_singular( array( 'market', 'service', 'product', 'case_studies' ) )) { unset ($trail['trail_end']); $erosion = get_post(113); $custom_breadcrumb_parent = get_field( "custom_breadcrumb" ); $post_title = get_the_title( $post_id ); $trail[1] = '<a href="../' . ( $erosion->post_name) . '" title="' . esc_attr( $erosion->post_title ) . '">' . esc_attr( $erosion->post_title ) . '</a>'; $trail[2] = '<a href="../' . ( $custom_breadcrumb_parent->post_name ) . '" title="' . esc_attr( $custom_breadcrumb_parent->post_title ) . '">' . esc_attr( $custom_breadcrumb_parent->post_title ) . '</a>'; $trail['trail_end'] = $post_title; } return $trail; }
August 20, 2020 at 9:53 pm #1239630 -
AuthorPosts
- You must be logged in to reply to this topic.