Php 为首页添加自定义规范-Yoast

Php 为首页添加自定义规范-Yoast,php,wordpress,Php,Wordpress,我想使用YOAST为首页添加自定义url。我正在尝试这种方法,但它没有任何作用,你能帮我吗 function design_canonical($url) { global $post; $url == ( 'www.cator.com/cator/'); } add_filter( 'wpseo_canonical', 'design_canonical' ); 知道问题出在哪里吗? 谢谢您首先需要检查您的页面是否为主页,您可以通过查看该页面是否为主页() 我添加了这个,但它

我想使用YOAST为首页添加自定义url。我正在尝试这种方法,但它没有任何作用,你能帮我吗

function design_canonical($url) {
    global $post;
    $url == ( 'www.cator.com/cator/');
}
add_filter( 'wpseo_canonical', 'design_canonical' );
知道问题出在哪里吗?
谢谢

您首先需要检查您的页面是否为主页,您可以通过
查看该页面是否为主页()


我添加了这个,但它仍然添加了主规范url,而不是它放在“yourcustomurl.com”中的规范url。你知道他为什么不工作吗?
function design_canonical($url) {

    if (is_home()) {
        return 'your-custom-url.com'; //Enter here your custom url
    } else {
        return $url;
    }
}

add_filter( 'wpseo_canonical', 'design_canonical' );