This topic has 3 replies, 2 voices, and was last updated 6 years by Laura.

  • Author
  • #197117
     tipinoncomuni
    Participant

    I want my breadcrumb shows a custom field text instead of the post title text.

    Is there a way to that?

    I have seen that i can customize the title but that customized text will be shown in the breadcrumb too.

    #197162
     Laura
    Moderator

    Hello, i am not sure i understand your request, can you share more details?

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #197165
     tipinoncomuni
    Participant

    A) The first page is “Aziende in Emilia Romagna” (Alaska Companies) – slug: “alaska” – custom field: “Alaska”
    B) The children page is “Aziende produttrici” (Farm Companies) – slug “producers” – custom fields “Producers”
    C) The children of the children page is “Aziende produttrici di Vegetali e Cereali” (Farm producing vegetables and cereals)

    The normal breadcrumb for page “C” is:
    Aziende in Emilia Romagna / Aziende produttrici / Aziende produttrici di Vegetali e Cereali
    That’s very long and unuseful
    I desire to use the custom fields values to create a better breadcrumb:
    Alaska / Producers / Vegetable & Cereals

    Is there a Kleo hook to force a custom breadcrumb?

    #197274
     Laura
    Moderator

    Hello, you could use the slug for breadcrumbs, try by adding this to functions.php of child theme

    If there is an error, go to your hosting file manager and delete the code you just added

    COPY CODE
    
    if ( is_page() ) {
                $post = $wp_query->get_queried_object();
                if ( $post->post_parent == 0 ){ echo "<li> » ".ucwords(str_replace("-", " ", $post->post_name))."</li>"; } 
                else {
                    $title = the_title('','', FALSE);
                    $ancestors = array_reverse( get_post_ancestors( $post->ID ) );
                    array_push($ancestors, $post->ID);
    
                    foreach ( $ancestors as $ancestor ){
                        if( $ancestor != end($ancestors) ){
                            echo '<li> » <a href="'. get_permalink($ancestor) .'">'. ucwords(str_replace("-", " ", basename(get_permalink($ancestor)))) .'</a></li>';
                        } else {
                            echo '<li> » '. ucwords(str_replace("-", " ", basename(get_permalink($ancestor)))) .'</li>';
                        }
                    }
                }
    } 
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

Viewing 4 posts - 1 through 4 (of 4 total)

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?