我们对一些索引/根站点页面使用了非常定制的WordPress版本,其中使用了定制的元框来定制永久链接。我们正在寻找的是一个自定义函数,它主要查看是否正在使用自定义永久链接字段,如果正在使用,则获取该字段作为规范url。这有助于搜索引擎索引重复内容,我们正准备使用Outbrain,它将对我们的规范URL进行爬行。
我遇到了这篇关于堆栈溢出的文章,但不确定如何根据需要进行编辑。
function design_canonical() {
global $post;
if ( get_post_type( $post->ID ) == \'design\' ) {
return site_url( \'/design/\' . $post->post_name );
} else {
// Leave blank and Yoast SEO will use default canonical for posts/pages
}
}
add_filter( \'wpseo_canonical\', \'design_canonical\' )
我在想post->ID
不需要\'design\'
以及return site_url
应该是我的自定义元框。如何正确编辑?