There are a couple of issues here.
- Your
WPSEO_Frontend::canonical
function should return a value so that when other parts of your code calls the function a value instead of void is returned. - Since
canonical
is a member function ofWPSEO_Frontend
you need to have an instance ofWPSEO_Frontend
to call thecanonical
function.
Update WPSEO_Frontend::canonical
function to return get_page_link()
:
<?php
class WPSEO_Frontend {
public function canonical() {
return get_page_link();
}
}
?>
Then in your seo_meta_tags
function use an instance of WPSEO_Frontend
to call canonical
:
<?php
function seo_meta_tags() {
$wp_seo_frontend = new WPSEO_Frontend();
echo '<meta property="og:url" content="' . $wp_seo_frontend->canonical() . '">' . PHP_EOL;
}
?>