breadcrumb.php 903 Bytes
<?php 
/**
 * Generate breadcrumbs
 * @author CodexWorld
 * @authorURL www.codexworld.com
 */


function get_breadcrumb() {

        $main_nav_items = wp_get_nav_menu_items('broker_main');
        $post_id = get_the_ID();

        $my_parent = null;
        
        foreach($main_nav_items as $ni) {
            if($ni->object_id == $post_id) {
                $parent_postID = wp_get_post_parent_id($post_id);
                if($parent_postID) {
                    $my_parent = get_post($parent_postID);
                }
            }
        }
    
        if(!$my_parent) return;

        ?>
            <ul class='breadcrumbs'>
                <?php if($my_parent) { ?>
                    <li><a href='<?= get_permalink($my_parent) ?>'><?= $my_parent->post_title ?></a></li><li>|</li>
                <?php } ?>
                <li><?= get_the_title() ?></li>
            </ul>
        <?php

}