You would need to look in the Yoast plugin to find what the global class is that is referred to as $this
, so that you can access it outside the class context. If it was for example, $wpseo
, in your functions.php you could do something like:
$wpseo = WPSEO_Frontend::get_instance();
remove_action( 'wpseo_head', array( $wpseo, 'canonical' ), 20 );
add_action( 'wpseo_head', array( $wpseo, 'canonical' ), 55 );
To find the class name to use, look for the name of the class that contains the add_action
with $this
in it as you have already, and then get the instance of that class, like $wpseo = WPSEO_Frontend::get_instance();
UPDATE changed code to reflect actual found and tested class instance.