Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #854301

    Is there some quick code I can add to functions.php that will change the shop name on the single product page? Everywhere else, it is working as expected and I get this:

    You are here:Home / Room Categories / Huddle Room Type / Huddle Room Presentation

    but, on the single product page, I get this:

    You are here: Home / Shop / Huddle Room Presentation Only / Huddle Room Standard

    I was hoping I could do something along these lines:

    add_filter( ‘avia_breadcrumbs_trail’, ‘avia_change_bc_trail’, 20, 2 );
    function avia_change_bc_trail( $trail, $args ){
    if( is_product() ) {
    unset( $trail[count($trail)-1] );
    }
    return $trail;
    }

    where instead of unsetting the shop crumb, I could set it specifically to display “room categories.”

    Thoughts?

    Thanks!
    Dan

    #854419

    Hey Dan,

    You can try something like this

    
    add_filter( 'avia_breadcrumbs_trail', 'avia_change_bc_trail', 20, 2 );
    function avia_change_bc_trail( $trail, $args ){
        if( is_product() ) {
    	   $trail[count($trail)-1] = "Whatever you need";
        }
        return $trail;
    }
    

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #854656

    Victoria,

    Thanks for the quick response! That code actually changes the last element in the breadcrumb trail. I want to change the 2nd. How would I go about that?

    When I implement it, I get this:
    You are here:
    Home / Shop / Focus Room Presentation Only / Whatever You Need

    I’d like the “Whatever You Need” to replace the “Shop” in the trail.

    Thanks!
    Dan

    #855604

    Hi,

    You can try to change the number that exists there, the -1
    and let us know if that will work for you

    Best regards,
    Basilis

    #856482

    So, I tried this and I realized I lost the hyperlink. I saw a few other posts about how to add that in, but it seems quite complicated. Then, I stubmled across this:
    https://kriesi.at/support/topic/rename-blog-title-and-breadcrumb/

    Which has this code in it:
    // Change Breadcrumb

    if(!function_exists(‘avia_modify_blog_breadcrumb’))
    {
    function avia_modify_blog_breadcrumb($trail)
    {
    foreach($trail as $key => $data)
    {
    $search = ‘SEO Tools to Equip Your Business – Blog’;
    if(strpos($data, $search) !== false)
    {
    $data = str_replace($search, “Blog”, $data);
    $trail[$key] = $data;
    }
    }
    return $trail;
    }

    add_filter(‘avia_breadcrumbs_trail’,’avia_modify_blog_breadcrumb’);
    }

    Seemed like just what I needed. I edited as so:
    if(!function_exists(‘avia_modify_woocommerce_breadcrumb’))
    {
    function avia_modify_woocommerce_breadcrumb($trail)
    {

    foreach($trail as $key => $data)
    {
    $search = ‘Shop’;
    if(strpos($data, $search) !== false)
    {
    $data = str_replace($search, “Room Categories”, $data);
    $trail[$key] = $data;
    }
    }
    return $trail;
    }

    }
    add_filter(‘avia_breadcrumbs_trail’,’avia_modify_woocommerce_breadcrumb’);
    }

    But, it still isn’t working. Did I go down a rabbit hole with this code? (I know just enough to be really, really dangerous.) LOL

    #856631

    Hi trellyn,

    Try the code below:

    
    add_filter( 'avia_breadcrumbs_trail', 'avia_change_bc_trail', 20, 2 );
    function avia_change_bc_trail( $trail, $args ){
        if( is_product() ) {
    	   $trail[1] = "Whatever you need";
        }
        return $trail;
    }
    

    If you need further assistance please let us know.
    Best regards,
    Victoria

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.