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

时间:2018-08-03 10:22:51

标签: php wordpress

我想使用YOAST为首页添加自定义网址。我正在尝试这种方法,但是它什么也没做,您能帮我吗?

function design_canonical($url) {
    global $post;
    $url == ( 'www.cator.com/cator/');
}
add_filter( 'wpseo_canonical', 'design_canonical' );

知道哪里出了问题吗? 谢谢

1 个答案:

答案 0 :(得分:1)

您首先需要检查您的信息页是否在家中,您可以通过is_home()

进行检查。
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' );