Hide Private in breadcrumb

Hi support team. I have pages with the breadcrumb element like this one here https://dev.mrckamouraska.com/developpement/developpement-economique/

This page is a child page of a private page. I have made it private to have the structure visible but no content and no access for the first level page.

I would like to get rid of the word Private : (Privé in french) and remove the link on the «Développement» word.

Hi,

Regretfully this will require custom development that is outside the scope of support we can offer.
But to give something to start with, you can try adding the code below in your child theme’s functions.php file.

 function x_breadcrumbs_items( $data, $args = array() ) {
    $args = apply_filters( 'x_breadcrumbs_items_args', wp_parse_args( $args, array(
      'item_before'      => '<li class="x-crumbs-list-item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">',
      'item_after'       => '</li>',
      'label_before'     => '<span itemprop="name">',
      'label_after'      => '</span>',
      'delimiter_before' => '<span class="x-crumbs-delimiter">',
      'delimiter_after'  => '</span>',
      'delimiter_ltr'    => '&rarr;',
      'delimiter_rtl'    => '&larr;',
      'current_class'    => 'x-crumbs-current',
      'anchor_atts'      => array( 'class' => 'x-crumbs-link', 'itemtype' => 'http://schema.org/Thing', 'itemprop' => 'item' ),
      'include_meta'     => true,
    ) ) );
    $output           = '';
    $breadcrumbs      = $data;
    $breadcrumb_count = count( $breadcrumbs );
    $delimiter        = ( is_rtl() ) ? $args['delimiter_rtl'] : $args['delimiter_ltr'];
    $delimiter_markup = ( empty( $delimiter ) ) ? '' : $args['delimiter_before'] . $delimiter . $args['delimiter_after'];
    $i = 1;
    foreach ( $breadcrumbs as $breadcrumb ) {
      $args['anchor_atts']['href'] = $breadcrumb['url'];
      if ( $i === $breadcrumb_count ) {
        if ( isset( $args['anchor_atts']['class'] ) ) {
          $args['anchor_atts']['class'] .= ' ' . $args['current_class'];
        } else {
          $args['anchor_atts']['class'] = $args['current_class'];
        }
        $args['anchor_atts']['title'] = __( 'You Are Here', '__x__' );
      }
      $output .= $args['item_before'];
        $output .= '<a ' . x_atts( $args['anchor_atts'] ) . '>';
          $output .= $args['label_before'] . str_replace("Privé","", $breadcrumb['label']) . $args['label_after'];
        $output .= '</a>';
        if ( $i !== $breadcrumb_count ) {
          $output .= $delimiter_markup;
        }
        if ( $args['include_meta'] ) {
          $output .= '<meta itemprop="position" content="' . $i . '">';
        }
      $output .= $args['item_after'];
      $i++;
    }
    return apply_filters( 'x_breadcrumbs_items', $output, $args );
  }

Thanks for understanding. Take care!

The good code is more simple:

add_filter( 'private_title_format', 'yourprefix_private_title_format' );
add_filter( 'protected_title_format', 'yourprefix_private_title_format' );
 
function yourprefix_private_title_format( $format ) {
    return '%s';
}

Problem solved.

Hi,

Glad you were able to figure it out.

Have a great day! :slight_smile:

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