• Resolved Funkphenomenon

    (@funkphenomenon)


    Suppose my URL structure is:
    domain.tld/books/ [overview of books]
    domain.tld/book/book-A/
    domain.tld/book/book-B/

    Currently, the breadcrumbs for book A are:
    Home > Book A

    I would like my breadcrumbs to be:
    Home > Overview of books > Book A

    (Whereby ‘Overview of books’ should link to the books overview page.) How do I accomplish that?

    I’m using the Yoast SEO plugin and Woocommerce, with which I managed to create a somewhat similar concept for Woocommerce products:

    add_filter( 'wpseo_breadcrumb_links', 'wpseo_breadcrumb_add_woo_shop_link' );
    function wpseo_breadcrumb_add_woo_shop_link( $links ) {
        global $post;
        if ( is_woocommerce() ) {
            $breadcrumb[] = array(
                'url' => get_permalink( wc_get_page_id( 'shop' ) ),
                'text' => get_the_title( get_page_by_path( 'webshop' ) ),
            );
            array_splice( $links, 1, -2, $breadcrumb );
        }
        return $links;
    }

    This is code I modified based on https://gist.github.com/amboutwe/ea0791e184668a5c7bd7bbe357c598e9

    However, I don’t know whether this concept also works for Pods, and if so, how to target Pods content types to create custom breadcrumbs.

Viewing 1 replies (of 1 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hello @funkphenomenon

    Pods merely creates the custom post type (in this case the Pod is a custom post type in WordPress).
    You can enable a default archive page in the settings but adding this to the breadcrumbs would be a question for Yoast SEO.

    If your archive page is a default WordPress page you could do something like this I suppose:

    add_filter( 'wpseo_breadcrumb_links', 'wpseo_breadcrumb_add_woo_shop_link' );
    function wpseo_breadcrumb_add_woo_shop_link( $links ) {
        global $post;
        if ( is_singular( 'book' ) ) {
            $page = get_page_by_path( 'books' );
            $breadcrumb[] = array(
                'url' => get_permalink( $page  ),
                'text' => get_the_title( $page ),
            );
            array_splice( $links, 1, -2, $breadcrumb );
        }
        return $links;
    }

    Cheers, Jory

Viewing 1 replies (of 1 total)
  • The topic ‘Custom breadcrumbs for Pods content types using Yoast SEO?’ is closed to new replies.