• Resolved Marc

    (@mdxfr)


    Hello Phi,

    What would be the best way to manage this frequent use case : the blog home is a single Page (and not the home page of the website), so we can have such a trail Home > Blog > my post path?

    • option 1 – rebuild everything for post type through the “breadcrumb_block_get_items” filter ?

    with a IF test like if ( is_singular('post') {

    • option 2 – set in WP Options > Read the Page as blog index ? Currently i always left this dropdown empty / not assigned

    How does the plugin manage this case ? what’s your advise ?

    • This topic was modified 5 months ago by Marc.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Phi Phan

    (@mr2p)

    Hi Marc @mdxfr, there isn’t a straightforward method to implement this change with this block. In my opinion, I would choose option 1, however you don’t have to rebuild the entire array, you just need to insert the blog item at the second position in the array. I should have placed a hook like do_action( 'breadcrumb_block_single_post', $post, $this ); before the single item. With that hook, you can easily add any item before any post. I will at that hook in the next version.

    Phi

    Thread Starter Marc

    (@mdxfr)

    ok, so i can play with the array, but i’ll wait for your hook.

    i did not have a look, but if you can make it possible to let us rename the value of this inserted path position, would be fine (in case the Blog Home Page has a long Title, the breacrumb value must be shorten by us).

    thx

    Plugin Author Phi Phan

    (@mr2p)

    @mdxfr I have already added the hook that allows you to change the title, url, and the attributes of each item. You can learn it from the updated description of the plugin.

    Plugin Author Phi Phan

    (@mr2p)

    @mdxfr?I’ve added a new hook breadcrumb_block_single_prepend to the latest version 1.0.14. Here is the code to prepend the blog page to all posts.

    add_action( 'breadcrumb_block_single_prepend', function ( $post, $breadcrumbs_instance ) {
              if ( 'post' === $post->post_type ) {
                $blog_id = get_option( 'page_for_posts');
                if ( $blog_id ) {
                  $breadcrumbs_instance->add_item( get_the_title( $blog_id ), get_permalink( $blog_id ) );
                }
              }
            }, 10, 2 );

    Phi.

    Thread Starter Marc

    (@mdxfr)

    thanks for this, works like a charm

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