What you need is get_post_meta
instead of get_post_type
This:
if ( get_post_type( $post->ID ) == 'design' ) {
Should be:
$meta = get_post_meta($post->ID,'your-meta-key',true);
if (!empty($meta)) {
Put altogether
function design_canonical_wpse_93717() {
global $post;
$meta = get_post_meta($post->ID,'your-meta-key',true);
if (!empty($meta)) {
return $meta; // assuming this is an absolute URL
}
}
add_filter( 'wpseo_canonical', 'design_canonical_wpse_93717' );
The else
conditional was spurious so I removed it, and I am assuming that the filter works as advertised. I don’t use WP-SEO.
Also, I am a bit concerns as usually filters work more like this:
function design_canonical_wpse_93717($url) {
global $post;
$meta = get_post_meta($post->ID,'your-meta-key',true);
if (!empty($meta)) {
$url = $meta; // assuming this is an absolute URL
}
return $url;
}
add_filter( 'wpseo_canonical', 'design_canonical_wpse_93717' );
That is, usually filters pull in content via a parameter and pass that content back out, but again I don’t use that plugin.