-
-
Save alanmcginnis/51c85c64d21c7db5122a4d3c22b1d566 to your computer and use it in GitHub Desktop.
Remove or modify the Yoast SEO prev or next URLs. Only copy the section of code you need.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/ | |
/* Change Yoast SEO Prev/Next URL on some pages | |
* Credit: Yoast Team | |
* Last Tested: Jun 10 2017 using Yoast SEO 4.9 on WordPress 4.8 | |
*/ | |
add_filter( 'wpseo_next_rel_link', 'custom_change_wpseo_next' ); | |
add_filter( 'wpseo_prev_rel_link', 'custom_change_wpseo_prev' ); | |
function custom_change_wpseo_next( $link ) { | |
/* Make the magic happen here | |
* Example below changes the rel=”next” link on your homepage | |
*/ | |
if ( is_home() ) { | |
$new_link = 'https://example.com/custom-page/2/'; | |
$link = '<link rel="next" href="'. $new_link .'" />' . PHP_EOL; | |
} | |
return $link; | |
} | |
function custom_change_wpseo_prev( $link ) { | |
/* Make the magic happen here */ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/ | |
/* Remove Yoast SEO Prev/Next URL from all pages | |
* Credit: Yoast Team | |
* Last Tested: Jun 10 2017 using Yoast SEO 4.9 on WordPress 4.8 | |
*/ | |
add_filter( 'wpseo_next_rel_link', '__return_false' ); | |
add_filter( 'wpseo_prev_rel_link', '__return_false' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/ | |
/* Remove Yoast SEO Prev/Next URL on some pages | |
* Credit: Yoast Team | |
* Last Tested: Jun 10 2017 using Yoast SEO 4.9 on WordPress 4.8 | |
*/ | |
add_filter( 'wpseo_next_rel_link', 'custom_remove_wpseo_next' ); | |
add_filter( 'wpseo_prev_rel_link', 'custom_remove_wpseo_prev' ); | |
function custom_remove_wpseo_next( $link ) { | |
/* Make the magic happen here | |
* Example below removes the rel=”next” link on your homepage | |
*/ | |
if ( is_home() ) { | |
return false; | |
} else { | |
return $link; | |
} | |
} | |
function custom_remove_wpseo_prev( $link ) { | |
/* Make the magic happen here | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment