Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #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 Page

    I have this set up pretty well, but it’s currently coming out as:
    Home > This Page > Permanent Page > Custom Page Relationship

    I 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.
    #1239623

    Hey 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,
    Yigit

    #1239624

    Hey 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;
    }
    
    #1239630

    Hi,

    Glad you figured it out and thanks for sharing your solution :)

    Best regards,
    Yigit

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.