Support » Plugin: Yoast SEO » Can't override canonical or rel links anymore

  • Bob Hennessey

    (@bob-hennessey)


    I just updated to the latest version of WordPress SEO (1.7.3.3). I noticed the code I wrote to intercept and tweak the canonical and rel next/prev links no longer works.

    This version doesn’t store its instance in $GLOBALS[‘wpseo_front’] anymore. Not sure if there’s a way around this in the newer version where I can get the instanct value of the front end, which is needed to remove the actions like ‘adjacent_rel_links’ that I want to override.

    The reason I override these is we have custom url structures to account for in some cases so I look for those specific cases and override where needed.

    https://wordpress.org/plugins/wordpress-seo/

Viewing 1 replies (of 1 total)
  • Thread Starter Bob Hennessey

    (@bob-hennessey)

    Figured it out:

    OLD CODE
    $wpseo_front = $GLOBALS[‘wpseo_front’];

    NEW CODE
    $wpseo_front = WPSEO_Frontend::get_instance();

    Then you can override functions like rel_links and use your own with code like:

    remove_action(‘wpseo_head’, array( $wpseo_front, ‘adjacent_rel_links’ ), 21 );
    add_action( ‘wpseo_head’, ‘my_adjacent_rel_links_function’ , 21 );

Viewing 1 replies (of 1 total)
  • The topic ‘Can't override canonical or rel links anymore’ is closed to new replies.