[OFFER ALERT!] This Halloween, Get Any Premium Theme for Just $19 [GET IT NOW]
Jump to content

[Rank Math SEO Plugin] Set Home URL in Breadcrumbs to Woocommerce SHOP URL


support40
 Share

Recommended Posts

Hi all,

Firstly, nice work my theme shop crew. I have De yoasted, and purchased WP Reviews Pro!

I've implemented the change to use Rank Math Breadcrumbs, but I could not find a way to link the SHOP base url. Only the HOME landing page is available.

Current state, I need to change the URL for HOME to point to the Woocommerce SHOP url. What is the best way of achieving this?

I would change to the word "STORE":
image.png.d2055158da0f39b0136b99735bbf1e89.png

And Link here to the "STORE" main page here:
image.png.19cdae4d3eab6a369625c93beedb43b4.png

What would I place in the CHILD Functions.php?

 

Thanks,

 

Jon.

 

Link to comment
Share on other sites

  • Support

Hello,

Thank you for sharing the code snippet.

It will definitely help others looking for a similar solution.

If you need any further assistance, please feel free to open a new support ticket. We are here to help.

  • Like 1

🏁Rank #1 on Google With our WordPress SEO Plugin

Score a 💯on PageSpeed and Dominate Search Rankings.

✏ Editing theme files? Please create a child theme to make your changes update-proof.

Link to comment
Share on other sites

  • Support

Hello,

Thank you for contacting MyThemeShop today.

From what I understand you only want to change the WooCommerce breadcrumbs. Is that correct?
That would require editing the WooCommerce breadcrumbs without Rank Math. 
Perhaps this documentation can help: https://docs.woocommerce.com/document/customise-the-woocommerce-breadcrumb/

Or you can perhaps using this plugin: https://wordpress.org/plugins/woocommerce-breadcrumbs/

We have also asked our lead developers to see if it is something we can implement in future versions of Rank Math.

Let us know if that helps.

Looking forward to helping you. Thank you.


🏁Rank #1 on Google With our WordPress SEO Plugin.

Score a 💯on PageSpeed and Dominate Search Rankings.

✏ Editing theme files? Please create a child theme to make your changes update-proof.

Link to comment
Share on other sites

Hi Mista, this is incorrect,

I am using Rank Math breadcrumbs not woocommerce breadcrumbs.

I have switched from the7 theme breadcrumbs to use Rank Math's breadcrumbs.

I want to change the Rank Math generated base url in the breadcrumbs (Homepage Link). This needs to point to the Base of the woocommerce shop.

How do we achieve this?

The Woocommerce link change code is this:

/**
 * Replace the home link URL
 */
add_filter( 'woocommerce_breadcrumb_home_url', 'woo_custom_breadrumb_home_url' );
function woo_custom_breadrumb_home_url() {
    return 'http://woocommerce.com';
}

How do we do this for Rank Math's home url?

I want "Home" set in Rank math breadcrumb code to point to 'https://captainvapour.co.nz/store/'

Thanks,

Jon

 

Findings for others using the7 theme:

On a side note for anyone using the7 theme, their kind support advised on the correct approach to make Rank Math breadcrumbs work in the7 theme. This is placed in the child's functions.php file:
function presscore_get_breadcrumbs(){
if(function_exists('rank_math_the_breadcrumbs'))
{
rank_math_the_breadcrumbs();
}
}

We still have an issue to rule out, as Rank Math breadcrumbs are appearing above the header, when its expected to be within the header. **Image shows where it needs to be. I'll update when they get back.
@Rank Math. I trust this is a theme issue?

image.thumb.png.7e6134f5dfa18541f2aabfc7cdddd98a.png

Edited by support40
More info
Link to comment
Share on other sites

  • Support

Hello,

To change Homepage link, please add below filter code in your theme's functions.php file:

add_filter( 'rank_math/frontend/breadcrumb/args', function( $args ) {
	$shop_page_url = get_permalink( wc_get_page_id( 'shop' ) );
	$args['wrap_before'] = '<nav class="rank-math-breadcrumb"><p><a href="'. $shop_page_url .'">Shop</a> <span class="separator"> - </span>';
	return $args;
});

 

6 hours ago, support40 said:

On a side note for anyone using the7 theme, their kind support advised on the correct approach to make Rank Math breadcrumbs work in the7 theme. This is placed in the child's functions.php file:
function presscore_get_breadcrumbs(){
if(function_exists('rank_math_the_breadcrumbs'))
{
rank_math_the_breadcrumbs();
}
}

We still have an issue to rule out, as Rank Math breadcrumbs are appearing above the header, when its expected to be within the header. **Image shows where it needs to be.

Are you sure presscore_get_breadcrumbs() function doesn't run above the header? The rank_math_the_breadcrumbs is just a function which output Breadcrumbs data where you placed it.

Hope that helps. Thank you.


🏁Rank #1 on Google With our WordPress SEO Plugin.

Score a 💯on PageSpeed and Dominate Search Rankings.

✏ Editing theme files? Please create a child theme to make your changes update-proof.

Link to comment
Share on other sites

This is excellent Pratik and works. I would need to switch the HOME setting in Rank Math off.

Order of Breadcrumbs:
While we are here, to be complete for others wanting to also keep "Home", how do we arrange "SHOP" to appear after "HOME"?

Thanks so much and Happy New Year!

image.png.97d76708516c26578ff08e7a385d5a5e.png

Edited by support40
Link to comment
Share on other sites

  • Support

Hello,

To change the position of Home & Shop in Breadcrumbs, please disable Show Homepage Link in Breadcrumb Settings and add below code in your theme's functions.php file:

add_filter( 'rank_math/frontend/breadcrumb/args', function( $args ) {
	$separator = RankMath\Helper::get_settings( 'general.breadcrumbs_separator' );
	$shop_page_url = get_permalink( wc_get_page_id( 'shop' ) );
	$args['wrap_before'] = '<nav class="rank-math-breadcrumb"><p>';
	$args['wrap_before'] .= '<a href="' . home_url() . '">'. RankMath\Helper::get_settings( 'general.breadcrumbs_home_label' ) .'</a> <span class="separator"> '. $separator .' </span>';
	$args['wrap_before'] .= '<a href="'. $shop_page_url .'">Shop</a> <span class="separator"> '. $separator .' </span>';

	return $args;
});

Hope that helps.

Thank you and Happy New year to you, too.


🏁Rank #1 on Google With our WordPress SEO Plugin.

Score a 💯on PageSpeed and Dominate Search Rankings.

✏ Editing theme files? Please create a child theme to make your changes update-proof.

Link to comment
Share on other sites

  • Support

Hello,

Glad that helped.

We would request you to take a couple of minutes to REVIEW the plugin and give it 5-STARS on WordPress.org, if not already
https://link.mythemeshop.com/reviewrankmath

Your kind words motivate us and help us put more effort into the development of this plugin and make it even better.

We really need your positive feedback to push even harder, keep the plugin FREE, and continue the development of the plugin in full-swing.

If you are planning to do a 4-star review or anything less, please don't. Instead, reply here and let us understand your requirements so we can get a 5-star rating from you as well. Can not afford even a single user to be disappointed over anything.

Thank you.

  • Like 1

🏁Rank #1 on Google With our WordPress SEO Plugin

Score a 💯on PageSpeed and Dominate Search Rankings.

✏ Editing theme files? Please create a child theme to make your changes update-proof.

Link to comment
Share on other sites

As discussed in email, there is another part after testing:

Full testing shows one last issue. Darn, I closed the ticket. :(
When on the SHOP page, store in my case, it has a double store listing.

How do we remedy this in functions.php? The first middle "store needs to go" when on SHOP page (store):
8BA574EF-E7B7-44FD-9769-5BD2EA2E57A1@fishcookie.local


 
Link to comment
Share on other sites

  • Support

Hello,

You can use is_shop() condition to check if the current page is a shop:

add_filter( 'rank_math/frontend/breadcrumb/args', function( $args ) {
	$separator = RankMath\Helper::get_settings( 'general.breadcrumbs_separator' );
	$shop_page_url = get_permalink( wc_get_page_id( 'shop' ) );
	$args['wrap_before'] = '<nav class="rank-math-breadcrumb"><p>';
	$args['wrap_before'] .= '<a href="' . home_url() . '">'. RankMath\Helper::get_settings( 'general.breadcrumbs_home_label' ) .'</a> <span class="separator"> '. $separator .' </span>';
	if( ! is_shop() ) {
		$args['wrap_before'] .= '<a href="'. $shop_page_url .'">Shop</a> <span class="separator"> '. $separator .' </span>';
	}

	return $args;
});

Hope that helps. Thank you.


🏁Rank #1 on Google With our WordPress SEO Plugin.

Score a 💯on PageSpeed and Dominate Search Rankings.

✏ Editing theme files? Please create a child theme to make your changes update-proof.

Link to comment
Share on other sites

Thanks Pratik, you guys have great support. Same goes for the7 theme support team.

For anyone not advanced with php like myself, here's what was was done for RankMath Breadcrumbs to function as expected with a different SHOP URL to the homepage:

Many thanks. Jon @ captainvapour.co.nz

/** Swap Breadcrumb from the7 to Rank Math 
*/
function presscore_get_breadcrumbs(){
if(function_exists('rank_math_the_breadcrumbs'))
{
return do_shortcode( '[rank_math_breadcrumb]');
}
}
/** Add Breadcrumb for Home and a link to Store front page 
*/
add_filter( 'rank_math/frontend/breadcrumb/args', function( $args ) {
    $separator = RankMath\Helper::get_settings( 'general.breadcrumbs_separator' );
    $shop_page_url = get_permalink( wc_get_page_id( 'shop' ) );
    $args['wrap_before'] = '<nav class="rank-math-breadcrumb"><p>';
    $args['wrap_before'] .= '<a href="' . home_url() . '">'. RankMath\Helper::get_settings( 'general.breadcrumbs_home_label' ) .'</a> <span class="separator"> '. $separator .' </span>';
    if( ! is_shop() ) {
        $args['wrap_before'] .= '<a href="'. $shop_page_url .'">SHOP</a> <span class="separator"> '. $separator .' </span>';
    }
    return $args;
});

Link to comment
Share on other sites

  • Support

Hello,

Thank you for sharing the code snippet.

It will definitely help others looking for a similar solution.

If you need any further assistance, please feel free to open a new support ticket. We are here to help.

  • Like 1

🏁Rank #1 on Google With our WordPress SEO Plugin

Score a 💯on PageSpeed and Dominate Search Rankings.

✏ Editing theme files? Please create a child theme to make your changes update-proof.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...