Add Breadcrumb Navigation

Implement breadcrumb navigation for improved site navigation.

<?php
function custom_breadcrumbs() {
    if (!is_home()) {
        echo '<nav class="breadcrumb">';
        echo '<a href="' . home_url() . '">Home</a> &raquo; ';
        if (is_category() || is_single()) {
            the_category(' &raquo; ');
            if (is_single()) {
                echo ' &raquo; ';
                the_title();
            }
        } elseif (is_page()) {
            echo the_title();
        }
        echo '</nav>';
    }
}
add_action('wp_before_main_content', 'custom_breadcrumbs');

Post Comment