• Resolved yann1ck

    (@ja4st3r)


    Hi Sybre,

    thank you very much for the smooth update to verison 5.0. I updated two sites without any problem!

    I have a very minor request: Is it possible to remove the current page from the breadcrumb trail? On my pages the breadcrumb trail is close to the page title, so it is duplicated information. I read in another support ticket that you plan improvements to the shortcode, but not sure if that is on your list.

    All the best
    Yannick

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hi Yannick,

    I’m glad everything went well!

    I added your request to my list. Currently, it is only possible via filters. Here’s one that I just created for this occasion:

    /**
     * Filters out TSF's last breadcrumb if at least 2 items are in the breadcrumb.
     * Only does this after wp_head to prevent affecting the structured data.
     * A better hook would've been <code>wp_body_open</code>, but not all themes have this yet.
     */
    add_action(
    	'wp_head',
    	function() {
    		add_filter(
    			'the_seo_framework_breadcrumb_list',
    			fn( $list ) => count( $list ) > 1 ? array_slice( $list, 0, -1 ) : $list,
    		);
    	},
    	PHP_INT_MAX,
    );

    Here, you can learn where to put filters: https://tsf.fyi/d/filters/#where.

    Thread Starter yann1ck

    (@ja4st3r)

    Hi Sybre,

    thank you very much for your response and your example. Why are you not using the “the_seo_framework_breadcrumb_shortcode_output” filter? Thats what I played with before going with a CSS only solution. Perhaps it is helpful for someone else.

    .tsf-breadcrumb .breadcrumb-item:not(:nth-child(-n + 2)):last-of-type {
        display:none;
    }
    
    .tsf-breadcrumb .breadcrumb-item:not(:nth-child(-n + 1)):nth-last-of-type(2)::after {
        display:none;
    }
    Plugin Author Sybre Waaijer

    (@cybr)

    Hello Yannick!

    It wasn’t apparent to me you wanted it removed from either the Schema.org output or the shortcode, so I created a filter that removed them both while mitigating the need for complicated CSS queries. But I’m glad you’ve found a workaround 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Breadcrumb shortcode remove current page’ is closed to new replies.