ricardo
4/1/2020 - 2:57 PM

Custom Yoast breadcrumbs


add_filter( 'wpseo_breadcrumb_links', 'override_yoast_breadcrumb_solution' );

function override_yoast_breadcrumb_solution( $links ) {
    global $post;

    if ( is_singular( 'solution' ) ) {
        $parent = get_post_ancestors( $post->ID );
        if(empty($parent)){
            $breadcrumb[] = array(
                'url' => get_permalink( 1 ), // TODO: Set correct page
                'text' => __('Solution', 'inline-admin'),
            );

            array_splice( $links, -1, 1, $breadcrumb );
        }

    }

    return $links;
}