Quantcast
Channel: Active questions tagged yoast - Stack Overflow
Viewing all articles
Browse latest Browse all 97

How to use Yoast SEO Premium properly

$
0
0

The Yoast plugin creates its own redirect map when the URLs of published posts are changed. We need a function that will run after changes are made to the redirect map.

But for some reasons, I can't make it work even I have a lot args


// This throws an error with: Uncaught ArgumentCountError: Too few arguments to function handle_yoast_term_redirect_slug_change(),  function handle_yoast_term_redirect_slug_change($create_redirect, $term_id, $term, $term_before) {     $old_slug = $term_before->slug;     $new_slug = $term->slug;     if ($old_slug !== $new_slug) {         $redirect_url = get_term_link($term_id, $term->taxonomy);         wp_redirect($redirect_url);         exit();     }     return $create_redirect; } add_filter('Yoast\WP\SEO\term_redirect_slug_change', 'handle_yoast_term_redirect_slug_change', 10, 4);

This is working pretty fine but when it comes to termRedirectSlug it won't

function handle_yoast_post_redirect_slug_change( $create_redirect, $post_id, $post, $post_before ) {     $old_slug = $post_before->post_name;     $new_slug = $post->post_name;     var_dump($old_slug, $new_slug);     if ( $old_slug !== $new_slug ) {         $redirect_url = get_permalink( $post_id );         var_dump($redirect_url);         wp_redirect( $redirect_url );         exit();     }     return $create_redirect; } add_filter( 'Yoast\WP\SEO\post_redirect_slug_change', 'handle_yoast_post_redirect_slug_change', 999, 4 );

Viewing all articles
Browse latest Browse all 97

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>