• Resolved schwimmlehrer

    (@schwimmlehrer)


    Hi this is a great plugin! On my site I have a separate page for posts and was thinking of changing this code so that the user gets to the posts page (my blog) instead the whole website:

    protected function add_crumbs_front_page() {
      //$this->add_item( __( 'Home', 'breadcrumb-block' ), esc_url( user_trailingslashit( home_url() ) ), [ 'rel' => 'home' ] );
      $this->add_item( __( 'Home', 'breadcrumb-block' ), esc_url( user_trailingslashit( get_post_type_archive_link( 'post' ) ) ), [ 'rel' => 'home' ] );		
    }

    It could be an option in the block settings, what do you think? Or does it make no sense? I have a similar breadcrumb on my woocommerce page where “home” points to the home of the store, not the home of the whole website.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Phi Phan

    (@mr2p)

    Hi @schwimmlehrer,

    Thank you for your feedback. I’ll look into it for a solution soon.

    Thanks, Phi.

    Plugin Author Phi Phan

    (@mr2p)

    Hi @schwimmlehrer,

    My first thought for this use case is adding two filter hooks like breadcrumb_block_home_url and breadcrumb_block_home_text

    The new code will be:

    $this->add_item( apply_filters( 'breadcrumb_block_home_text', __( 'Home', 'breadcrumb-block' ) ), esc_url( user_trailingslashit( apply_filters( 'breadcrumb_block_home_url', home_url() ) ) ), [ 'rel' => 'home' ] );

    The code to alter the home url and text will be:

    add_filter( 'breadcrumb_block_home_url', function ( $url ) {
      return 'new_url';
    } );
    
    add_filter( 'breadcrumb_block_home_text', function ( $text ) {
      return 'new text';
    } );

    What do you think this quick solution?

    Thread Starter schwimmlehrer

    (@schwimmlehrer)

    I like it! That way I could also change the Text to “Blog” so that the user knows that he goes back to the Blog page. More flexible than adding it as an option to the block ui.

    Plugin Author Phi Phan

    (@mr2p)

    Okay, I’ll release a new version for it very soon.

    Phi.

    Plugin Author Phi Phan

    (@mr2p)

    Hi @schwimmlehrer,

    Please test it on the latest version 1.0.6

    Thank you for your feeback again.

    Phi.

    Thread Starter schwimmlehrer

    (@schwimmlehrer)

    I tested it, works very well. Thank you

    Plugin Author Phi Phan

    (@mr2p)

    Thank you @schwimmlehrer for your feedback.

    If you have a moment, please help this plugin grow by giving it a ratting as well.

    Thanks, Phi.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Suggestion: Home Link pointing to Blog’ is closed to new replies.