• Resolved p4ssc3

    (@passce)


    Hi,

    I would like to hide the shop page in the breadcrumb (on my category page and product page) because I don’t use the shop page (I use direct link to the severals categories) so it confused my visitors to have this page in the breadcrumb .

    There is a hook / snippet for that ?
    Thanks!!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Maybellyne

    (@maybellyne)

    Hello,

    Thanks for reaching out.

    To edit the breadcrumbs pathway use the filter below and place it in your child theme’s functions.php file:

    wpseo_breadcrumb_links

    We also have some examples of how to edit and remove breadcrumbs. If you are not sure how to use them, where your functions.php file is, or what a child theme is please contact your theme developer for more information.

    Also, if you’re not familiar with using code snippets, we’d like to refer you to the WordPress documentation on how to use a filter.

    Thread Starter p4ssc3

    (@passce)

    Also, I try to remove the “default_product_cat” (uncategorized) in the breadcumbs in woocommerce
    How can I do that ?

    Thanks very much

    • This reply was modified 3 years, 4 months ago by p4ssc3.
    • This reply was modified 3 years, 4 months ago by p4ssc3.
    Thread Starter p4ssc3

    (@passce)

    Can I use this snippet, for remove and not add ?
    I don’t know how to personalize this…
    Thanks

    add_filter( 'wpseo_breadcrumb_links', 'wpseo_breadcrumb_add_woo_shop_link' );
    
    function wpseo_breadcrumb_add_woo_shop_link( $links ) {
        global $post;
    
        if ( is_woocommerce() ) {
            $breadcrumb[] = array(
                'url' => get_permalink( woocommerce_get_page_id( 'shop' ) ),
                'text' => 'Shop',
            );
    
            array_splice( $links, 1, -2, $breadcrumb );
        }
    
        return $links;
    }
    • This reply was modified 3 years, 4 months ago by p4ssc3.
    • This reply was modified 3 years, 4 months ago by p4ssc3.
    • This reply was modified 3 years, 4 months ago by p4ssc3.
    • This reply was modified 3 years, 4 months ago by p4ssc3.
    Thread Starter p4ssc3

    (@passce)

    I think I have found how to hide the uncategorized :

    add_filter( 'wpseo_breadcrumb_links', 'your_prefix_wc_remove_uncategorized_from_breadcrumb' );
    
    function your_prefix_wc_remove_uncategorized_from_breadcrumb( $crumbs ) {
    	$category 	= get_option( 'default_product_cat' );
    	$caregory_link 	= get_category_link( $category );
    
    	foreach ( $crumbs as $key => $crumb ) {
    		if ( in_array( $caregory_link, $crumb ) ) {
    			unset( $crumbs[ $key ] );
    		}
    	}
    
    	return array_values( $crumbs );
    }

    (found on the other site)

    Thread Starter p4ssc3

    (@passce)

    Okay I think I found it :

    add_filter( 'wpseo_breadcrumb_links', 'wpseo_breadcrumb_remove_shop_link' );
    
    function wpseo_breadcrumb_remove_shop_link( $crumbs ) {
        global $post;
    
        if ( is_woocommerce() ) 
    	{
    	$shop_link 	= get_permalink( woocommerce_get_page_id( 'shop' ) );
    
    			foreach ( $crumbs as $key => $crumb ) 
    			{
    					if ( in_array( $shop_link, $crumb ) )
    					{
    						unset( $crumbs[ $key ] );
    					}
    			}	
    			
    	}
    	
    	return array_values( $crumbs );
    
    }

    Sorry for the spamming lol, maybe it will be usefull for someone else ?

    Plugin Support Md Mazedul Islam Khan

    (@mazedulislamkhan)

    Thanks for sharing the relevant code snippet, @passce. We are glad to hear that you were able to figure it out by yourself.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Breadcrumb : Hide the shop page’ is closed to new replies.