Breadcrumbs problem

#853532
  • Resolved Vladimir
    Rank Math free

    I would need to display the subcategories of product in the store on product in breadcrumbs. I used this code from your forum:

    add_filter( ‘rank_math/frontend/breadcrumb/main_term’, function( $term, $terms ) {

    $child_terms = get_term_children( $term->term_id, $term->taxonomy );
    if ( empty( $child_terms ) ) {
    return $term;
    }

    $child_term = get_term_by( ‘term_id’, end( $child_terms ), $term->taxonomy );

    return $child_term;
    }, 10, 2 );

    The code is currently not used.

    Subcategories are shown but incorrectly. Can you please help me? Thank you

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    We apologize for the issue you are facing with displaying subcategories in the breadcrumbs. Thank you for raising this concern.

    The code you provided is intended to replace the main term in the breadcrumbs with the last child term of the current term. However, if the subcategories are showing incorrectly, it might be due to how the terms are being retrieved or displayed.

    Here are a few things you can check:

    1. Ensure that the taxonomy is correct: Make sure that the taxonomy you are using in get_term_children() and get_term_by() is the correct one for your product categories.
    2. Debugging: You can add some debugging statements to see what terms are being retrieved. For example, log the $child_terms and $child_term to see if they are returning the expected values.
    3. Check for conflicts: Ensure that no other plugins or theme functions are interfering with how breadcrumbs are generated.

    If you continue to experience issues, please reply to this ticket, and a human agent from the Rank Math Support team will take over and assist you further.

    Thank you for your patience!

    Sources:
    How to Make Your Theme Rank Math Compatible » Rank Math

    Hello,

    To display the child category, you may need to choose it as the primary category of your product.

    You should select the subcategory as the primary category for your product here:
    https://rankmath.com/kb/how-to-choose-a-primary-category/#how-to-choose-a-primary-category

    Looking forward to helping you.

    It works. Thank you. You can close the ticket.:)

    Hello,

    We are super happy that this issue is already resolved. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind us asking, could you please leave us a review (if you haven’t already) on
    https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post

    about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)

The ticket ‘Breadcrumbs problem’ is closed to new replies.