how to add Simple breadcrumbs to the divi wordpress theme without a plugin

Knowledgebase

You can use the snippet below to add clickable breadcrumbs to Divi.

<pre>
<code>

<?php
/*
Plugin Name: Breadcrumb Shortcode
*/

function breadcrumb_shortcode() {
global $post;

// Initialize the breadcrumb array
$breadcrumb = array();

// Add the current post to the breadcrumb array
array_unshift($breadcrumb, $post);

// Loop through the parent posts and add them to the breadcrumb array
while($post->post_parent) {
$post = get_post($post->post_parent);
array_unshift($breadcrumb, $post);
}

// Create the breadcrumb string
$breadcrumb_string = ”;
foreach($breadcrumb as $crumb) {
$breadcrumb_string .= ‘<a href=”‘ . get_permalink($crumb->ID) . ‘”>’ . $crumb->post_title . ‘</a> / ‘;
}

// Remove the last “/” from the breadcrumb string
$breadcrumb_string = rtrim($breadcrumb_string, ” / “);

return $breadcrumb_string;
}
add_shortcode(‘breadcrumb’, ‘breadcrumb_shortcode’);

</code>
</pre>