自定义分类法的面包屑问题

I have a custom post type and custom taxonomies. Hierarchy of the pages is like this that first listing page is displayed. In listing page categories are also displayed.

If user is on listing page breadcrumbs is like this. Home/Projects and it is proper and working fine.

If user clicks on some category than breadcrumb is like this . Home/Project/category-1 . I also works fine.

ERROR:

If user clicks on any project than breadcrumb and its links are not proper.

Home/Projects/Projects-Catcategory-1/Al Murabit and its link is also like this.

code

      $ref1 = parse_url(wp_get_referer());
    if($taxonomy_names[0] )//||is_term()||is_singular())
    {
        echo '<li><a href="' . $homeLink . '/' . $slug['slug'] . 's/">' . $post_type->labels->singular_name . '6</a></li>';
        if(str_replace('/','',str_replace($taxonomy_names[0],'',$ref1['path'])))
        {
            echo '<li><a href="' . $homeLink . '/' . $taxonomy_names[0] . '/'.
            str_replace('/','',str_replace($taxonomy_names[0],'',$ref1['path'])).'">' .
            str_replace('/','',str_replace($taxonomy_names[0],'',$ref1['path'])) . '30</a></li>';

        }
    }