Custom Breadcrumb Title Incorrect for Product Tags

#130213
  • Resolved Wiseinternet
    Rank Math free

    Problem 1:
    The custom breadcrumb title when used for WooCommerce product tags “Rank Math > Advanced > Breadcrumb Title” does not operate correctly.

    If the user wants to use a custom breadcrumb title then I believe their custom title should overwrite any plugin text.

    Therefore the ‘Products tagged “…”‘ text and apostrophes should be replaced completely by the users’ custom title.

    Line 350: publicwp-contentpluginsseo-by-rank-mathincludesfrontendclass-breadcrumbs.php
    /**
    * Product tag trail.
    */
    private function add_crumbs_product_tag() {
    $term = $GLOBALS[‘wp_query’]->get_queried_object();
    $this->prepend_shop_page();
    /* translators: %s: product tag */
    $this->add_crumb( sprintf( __( ‘Products tagged “%s”‘, ‘rank-math’ ), $this->get_breadcrumb_title( ‘term’, $term, $term->name ) ) );
    }

    Problem 2:
    When Rank Math SEO Meta is enabled for a taxonomy the taxonomy admin page displays two “Description” editors.
    Only the second editor saves content, the first editor displayed is an error.

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

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for the delay and for any inconvenience this issue may have caused you.

    I’ve checked your site, and it seems that it’s getting an HTTP error 500. Could you please check? Please see screenshot in the designated Sensitive Data section.

    Thank you, and we really look forward to helping you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hello,

    Issue #1

    To do that you need to make sure that you change the Woocommerece breadcrumbs with Rank Math breadcrumbs. To be able to change that you need to put this on your functions.php

    
    /**
     * Add Rank Math Breadcrumbs 
     */
    add_action(
        'woocommerce_before_main_content', 'woocommerce_custom_breadcrumb'
    );
    function woocommerce_custom_breadcrumb(){
        echo do_shortcode('[rank_math_breadcrumb]');
    }
    /**
     * Remove the old breadcrumbs 
     */
    add_action( 'init', 'woo_remove_wc_breadcrumbs' );
    function woo_remove_wc_breadcrumbs() {
        remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
    }
    

    So we assume that you change the breadcrumbs already. To change the product tag breadcrumbs title. You need to add this to your functions.php. Here is the screenshot of the working sample https://i.rankmath.com/OaNTnt

    
    /**
     * Allow changing or removing the Breadcrumb items
     *
     * @param array       $crumbs The crumbs array.
     * @param Breadcrumbs $this   Current breadcrumb object.
     */
    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
    	$crumbs[1][0] = 'Custom Title';
    	return $crumbs;
    }, 10, 2);
    

    Issue #2
    Seems like your login information still not working. Please update your login information so we can help you to fix your issue with the duplicate taxonomy editor.

    We really look forward to helping you.

    Thank you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Issue #1:
    Unfortunately your code does not work to fix the problem raised, please check the breadcrumb in the URLs provided.
    Currently the example URL I have provided displays breadcrumb as follows:
    Home / Catalogue / Products tagged “Custom Tag for Access”
    Your code incorrectly changes this to:
    Home / Custom Title / Products tagged “Custom Tag for Access”
    The correct breadcrumb when using custom breadcrumb title should be this:
    Home / Catalogue / Custom Tag for Access
    The problem lies in this function:
    private function add_crumbs_product_tag()
    Issue #2:
    See the problem in any taxonomy/tag with “Add SEO Meta Box” enabled.

    Febby
    Rank Math free

    Hello,

    Thank you for letting us know.

    For issue #1,
    We have updated the custom tag access title in your site using the code below. You can found the code in the snippet plugin.

    Please refer to the screenshot below:
    ss-1

    /**
     * Allow changing or removing the Breadcrumb items
     *
     * @param array       $crumbs The crumbs array.
     * @param Breadcrumbs $this   Current breadcrumb object.
     */
    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
    	if(is_product_tag('access')){
    		$crumbs[2][0] = 'Custom Tag for Access';
    	}
    	return $crumbs;
    }, 10, 2);
    

    For Issue #2,
    This particular plugin is causing a duplicate editor on your site.

    Please see screenshot below:
    ss-2

    We think that you don’t need that since Rank Math got that feature.

    Please deactivate that plugin and use Rank Math Add SEO Meta Box feature instead.

    I hope this helps resolve your issue. Let us know if you need further help.

    Thank you.

    Issue #1 Not Resolved:
    The problem is with the text “Products tagged” being added in your private function “add_crumbs_product_tag”.
    Sure, your code example fixes one tag, but there are hundreds, so the function needs to be fixed or simply add a filter to the function allowing developers to remove “Products tagged”.

    Issue #2:
    Yes, we can turn off the plugin (not ideal), or we can hide the Rank Math description editor.

    Hello,

    Thank you for the follow up.

    #1 The code we have provided s enough to do all you need to customize the breadcrumbs. To have the code take effect on all tag pages then you can simply remove the tag page specified in the filter and automatically get the title tag from the page and assign it to be used as follows:

    
    /**
     * Allow changing or removing the Breadcrumb items
     *
     * @param array       $crumbs The crumbs array.
     * @param Breadcrumbs $this   Current breadcrumb object.
     */
    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
    	if(is_product_tag()){
    		$text = wp_title( '|', false );
    		$crumbs[1][0] = $text;
    	}
    	return $crumbs;
    }, 10, 2);
    

    #2. To hide Rank math description editor you will need to disable the option to add SEO meta box for your product tags in Rank math > Titles & Meta

    Hope this helps

    Problem #1:
    Wouldn’t it be logical to add a filter to a function whenever you hardcode custom text into your plugin, e.g. in the private function add_crumbs_product_tag()?
    The code you provided does not work to fix the issue raised, however something like the following will:

    /**
     * Allow changing or removing the Breadcrumb items
     *
     * @param array  $crumbs The crumbs array.
     * @param array	 $class  Current breadcrumb object.
     */
    add_filter(
    	'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
    		if ( is_product_tag() ) {
    			$tag_text = $crumbs[2][0];
    			if ( ! empty( $tag_text ) ) {
    				$tag_text     = str_replace( 'Products tagged “', '', $tag_text );
    				$tag_text     = str_replace( '”', '', $tag_text );
    				$crumbs[2][0] = $tag_text;
    			}
    		}
    		return $crumbs;
    	}, 10, 2
    );

    Hello,

    Thank you for the follow up.

    We do not usually provide code customizations. The code I shared with you was working on my end to replace the Products Tagged with the title of the tag.

    That said if your code has worked on your end, well and good.

    Let us know if you have nay further questions.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

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

The ticket ‘Custom Breadcrumb Title Incorrect for Product Tags’ is closed to new replies.