Add custom taxonomy to the breadcrum

#754206
  • Resolved Steve Ayo
    Rank Math free

    I have created a custom taxonomy, I want it to show up in the rank math permalink how can I do that?

    register_taxonomy( ‘service_cat’, array(‘services’), $args );

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for reaching out with your query about adding a custom taxonomy to the Rank Math breadcrumbs. To display a custom taxonomy in the breadcrumbs generated by Rank Math, you can follow these steps:

    1. Navigate to Rank Math Breadcrumbs Settings: Go to your WordPress Dashboard and then to Rank Math SEO → General Settings → Breadcrumbs.

    2. Enable Custom Taxonomy in Breadcrumbs: Unfortunately, Rank Math does not have a built-in option to directly add custom taxonomies to the breadcrumbs. However, you can achieve this by adding a custom code snippet to your theme’s template files.

    3. Add Custom Code Snippet: You will need to add a custom filter function to modify the breadcrumbs and include your custom taxonomy. Here is an example of how you can achieve this:

    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
        // Check if you are on a page where you want to display the custom taxonomy
        // You can modify this condition based on your requirements
        if ( is_singular( 'services' ) ) {
            // Add your custom taxonomy to the breadcrumbs
            $custom_taxonomy = get_the_terms( get_the_ID(), 'service_cat' );
            if ( $custom_taxonomy ) {
                foreach ( $custom_taxonomy as $term ) {
                    $term_link = get_term_link( $term );
                    $term_list = [ $term->name, $term_link ];
                    array_splice( $crumbs, 2, 0, array( $term_list ) );
                }
            }
        }
        return $crumbs;
    }, 10, 2 );
    1. Modify the Code: In the provided code snippet, make sure to replace 'services' with the appropriate post type where you want to display the custom taxonomy, and 'service_cat' with the name of your custom taxonomy.

    By adding this custom filter function to your theme’s template files, you should be able to display your custom taxonomy in the Rank Math breadcrumbs on the specified pages.

    If you encounter any issues or need further assistance with this customization, please feel free to reach out to our dedicated support team here. We are available 24/7 to assist you.

    I hope this helps! Let me know if you have any more questions or need further clarification.

    Sources:
    How to Customize Breadcrumbs in Rank Math » Rank Math
    How to Enable Breadcrumbs on Your Website With Rank Math SEO » Rank Math

Viewing 1 replies (of 1 total)

You must be logged in to reply to this ticket.