-
AuthorPosts
-
September 20, 2017 at 11:39 am #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!
DanSeptember 20, 2017 at 4:06 pm #854419Hey 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,
VictoriaSeptember 21, 2017 at 8:10 am #854656Victoria,
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 NeedI’d like the “Whatever You Need” to replace the “Shop” in the trail.
Thanks!
DanSeptember 22, 2017 at 10:07 pm #855604Hi,
You can try to change the number that exists there, the -1
and let us know if that will work for youBest regards,
BasilisSeptember 25, 2017 at 2:35 pm #856482So, 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 Breadcrumbif(!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
September 25, 2017 at 5:50 pm #856631Hi 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 -
AuthorPosts
- You must be logged in to reply to this topic.