Change nam of "blog"

Hello, my news page (blog post) is currently a normal page with an Essential Grid. Works fine. However, once i click on a post my breadcrumb is not showing the correct path. If i let wordpress read my news page as the blog page then the breadcrumb works fine, but my essential grid is not showing. Any ideas how i can fix this?

Thanks!
Blog page: https://jittysamsterdam.com/nieuws-trends/

Thanks!

Hi There @RPronk

Thanks for writing in! Since you’re just using a page (not a Blog setup), it will not identify it as a Blog main index page, when you’re inside single posts.

Please follow this detailed post to implement a workaround for this (https://theme.co/apex/forum/t/modify-the-breadcrumb-element/24923/4?u=mldarshana).

For example, you will need to replace it with a similar code as follows.

foreach ( $crumbs as $i => $crumb ) {
    if ( $crumb['label'] === 'Blog' ) {
      $crumbs[$i]['label'] = 'Nieuws & Trends';
       $crumbs[$i]['url'] = 'https://jittysamsterdam.com/nieuws-trends/';
    }
  }

You need to setup a child theme first (https://theme.co/apex/forum/t/setup-how-to-setup-child-themes/57) and implement your WordPress filter in your child theme’s functions.php file.

You can also read more about filters from here (https://theme.co/apex/forum/t/customizations-actions-and-filters-in-x-pro/208).

Thanks!

Thanks i get you. I have tried but have not succeeded. I will ask my colleague who has a bit more of understanding of php to do this. Thanks

I see a more serious issue. The category’s are not pulled in the breadcrumb. Would that be possible? I need to rebuild a site where this feuture is active. Example : https://www.jitty.nl/david-beckham-kapsel-geknipt-door-jittys-hair-and-make-up/

Hello @RPronk,

Thanks for updating the thread. :slight_smile:

Please try out the solution mentioned in following thread and let us know the outcome:

Thanks.

As i understand a bit of your code i do not know where to paste it. I have tried in Pro/framework/functions/frontend/breadcrumbs.php but have not succeeded.

For this specific task can i hire development with themeco?

Thanks

Hi,

You need to add the code to your child theme’s functions.php file.
It’s in wp-content/themes/pro-child/functions.php

In case you haven’t setup a child theme yet, please follow our guide below

Thanks

Ok thank you. Last code works, but not with the result i need. I do not know if this is possible in PRO. The breadcrumb needs to be something like this: home➝nieuws&trends➝haar➝Jitty’s-tips➝makkelijk-opsteken

So i need to all the name of the blog (nieuws & trends) and the category name in the breadcrumb. Is that possible?

ok i got the first code also working, now the name of the blog is replaced by the “nieuws & trends” thank you for this. But this leaves me with the question is it possible to pull the name of the category in the breadcrumb?

https://jittysamsterdam.com/makkelijk-opsteken/ should have breadcrump: home➝nieuws&trends➝haar➝Jitty’s-tips➝makkelijk-opsteken

Thanks!!!

Hi @RPronk,

You could combine the two, example,

function my_custom_breadcrumbs( $crumbs, $args ) {

$crumb_index = false ;

foreach ( $crumbs as $i => $crumb ) {
    if ( $crumb['label'] === 'Blog' && is_singular('post') ) {

      $crumbs[$i]['label'] = 'Nieuws & Trends';
       $crumbs[$i]['url'] = 'https://jittysamsterdam.com/nieuws-trends/';
       $crumb_index = $i + 1; //prevent zero for splicing
       break;

    }
}


if( $crumb_index ) {

    $category = get_the_category( get_the_ID() );

    if ( count( $category ) > 0 ) {
    
    array_splice( $crumbs, $crumb_index, 0, array('label' => $category[0]->name, 'url' => get_category_link( $category[0]->term_id ), 'type' => 'category') );

    }
	

}

return $crumbs;

}



add_filter( 'x_breadcrumbs_data', 'my_custom_breadcrumbs', 10, 2 );

I recommend contacting a developer for further enhancement.

Thanks!

Thanks! I understand this is outside the scope of support. Thanks for your time!

You’re welcome! :slight_smile:

Sorry to keep you guys busy with this :roll_eyes:

Ok i just received a mail saying you guys will give it one more shot, thank you for this!!!

Ok this part of code works like a charm:

       foreach ( $crumbs as $i => $crumb ) {
    if ( $crumb['label'] === 'Blog' ) {
      $crumbs[$i]['label'] = 'Nieuws & Trends';
       $crumbs[$i]['url'] = 'https://jittysamsterdam.com/nieuws-trends/';
    }
  }

This part of code works also like a charm,

add_filter('x_breadcrumbs_data', 'post_parent_trail', 9999999, 2);

function post_parent_trail ($crumbs, $args) {
  if ( is_singular('post') ) {

    $category = get_the_category( get_the_ID() );
    if ( count( $category ) > 0 ) {
    $crumbs[1]['label'] = $category[0]->name;
    $crumbs[1]['url'] = get_category_link( $category[0]->term_id );
    
   unset($crumbs[2]); //to make sure category won't duplicate

    }
  }
  return $crumbs;
}

So individually both set of codes do exactly what they supposed to do. The last attempt to combine these two results in failures

If you need any more info on this let me know,
Thousand thanks!!!

Last bit of provided code works!!!

I am very thankful for this. Kudos to you guys at Themeco!!! THANK YOU!!! :grinning::tada::tada:

(working code)

function my_custom_breadcrumbs( $crumbs, $args ) {

$crumb_index = false ;

foreach ( $crumbs as $i => $crumb ) {
    if ( strtolower( $crumb['label'] ) === 'blog' && is_singular('post') ) {

      $crumbs[$i]['label'] = 'Nieuws & Trends';
       $crumbs[$i]['url'] = 'https://jittysamsterdam.com/nieuws-trends/';
       $crumb_index = $i + 1; //prevent zero for splicing
       break;

    }
}


if( $crumb_index ) {

    $category = get_the_category( get_the_ID() );

    if ( count( $category ) > 0 ) {
    
    return array_merge ( array_slice($crumbs, 0, $crumb_index, true), array( array( 'label' => $category[0]->name, 'url' => get_category_link( $category[0]->term_id ), 'type' => 'archive' ) ), array_slice($crumbs, $crumb_index, count($crumbs)-$crumb_index, true) );

    }
	

}

return $crumbs;

}



add_filter( 'x_breadcrumbs_data', 'my_custom_breadcrumbs', 10, 2 );

You’re most welcome!

1 Like

And this was necessary as well: https://theme.co/apex/forum/t/breadcrumbs-fix-for-structured-data-pro-2-3-8/46836

One last question to close this topic. I have successfully implemented the change mentioned here https://theme.co/apex/forum/t/breadcrumbs-fix-for-structured-data-pro-2-3-8/46836 in my PRO theme and it works perfectly! Can i save this also to my Child theme so it will not get lost after updating? If so would i need ti replicate folder structure and save the modified breadcrumps.php there?

Thanks

Hi @RPronk,

It should be done through child theme functions.php, you don’t need to copy the breadcrumps.php template and any change on the child theme shouldn’t be overwritten by updates. Your child theme’s functions.php should serve as a backup as well :slight_smile:

Thanks!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.