Criando breadcrumbs no seu tema Wordpress sem plugin

by Robson Moulin

HTML

// BREADCRUMBS  --------------------------------------------------------------------------------------------------------

function custom_breadcrumbs() {
       
    // Configuracoes
    $separator          = '/';
    $breadcrums_id      = 'breadcrumbs';
    $breadcrums_class   = 'breadcrumb';
    $home_title         = 'Home';
      
    // Se você tiver algum tipo de postagem personalizado com taxonomias personalizadas, coloque o nome da taxonomia abaixo (e.g. product_cat)
    $custom_taxonomy    = 'product_cat';
       
    // Obter as informações de consulta e publicação
    global $post,$wp_query;
       
    // Não exibir na página inicial
    if ( !is_front_page() ) {
       
        // Construa o breadcrumbs
        echo '<ul id="' . $breadcrums_id . '" class="' . $breadcrums_class . '">';
           
        // Home page
        echo '<li class="item-home"><a class="bread-link bread-home" href="' . get_home_url() . '" title="' . $home_title . '">' . $home_title . '</a></li>';

           
        if ( is_archive() && !is_tax() && !is_category() && !is_tag() ) {
              
            echo '<li class="item-current item-archive"><span class="bread-current bread-archive">' . post_type_archive_title($prefix, false) . '</span></li>';
              
        } else if ( is_archive() && is_tax() && !is_category() && !is_tag() ) {
              
            // Se post é um tipo de postagem personalizado
            $post_type = get_post_type();
              
            // Se for um nome e link de exibição de tipo de postagem personalizado
            if($post_type != 'post') {
                  
                $post_type_object = get_post_type_object($post_type);
                $post_type_archive = get_post_type_archive_link($post_type);
              
                echo '<li class="item-cat item-custom-post-type-' . $post_type . '"><a class="bread-cat bread-custom-post-type-' . $post_type . '" href="' . $post_type_archive . '" title="' ....