I'm having some trouble setting a custom canonical title using the Wordpress SEO API: http://yoast.com/wordpress-seo-api-docs/
I have a custom post type called designs which uses a custom URL rewrite. It takes the base page /design/ and adds the design name to it like /design/a-design/. The canonical in Wordpress SEO by default is the /design/ page.
What I want to do is write a function which determines if it is a design page and return a different canonical. I can test whether it's a design page by doing if ($design == ""){ and I tried to use the custom permalink URL, but the function just removes the canonical completely.
Here's my basic function:
function design_canonical(){
if ($design == "") {
// Leave blank and Yoast SEO will use default canonical for posts/pages
}
else {
return $design['detailslink'];
}
}
add_filter( 'wpseo_canonical', 'design_canonical' )
Quite clearly doing something wrong, but I'm not entirely sure what.