如何将 Achnor 添加到分类 link

How Add Achnor to taxonomy link

我正在尝试在我的代码中放置一个锚点 以便链接指向 #here

例如

mysite/property/?jsf=jet-engine&tax=property_type:9 #here

add_filter('term_link', function ($termlink, $term, $taxonomy) {
   
    // taxonomy type
    if ('property_type' == $taxonomy) {
        $termlink = trailingslashit(get_home_url()) . 'property/?jsf=jet-engine&tax=property_type:' . $term->term_id;  
    }
    
    // taxonomy city
    if ('property_city' == $taxonomy) {
        $termlink = trailingslashit(get_home_url()) . 'property/?jsf=jet-engine&tax=property_city:' . $term->term_id;
    }
    
    return $termlink;
}, 10, 3);

我觉得一定是.$anchor. '#here';

但这似乎不是正确的方法..(PHP 致命错误)

add_filter('term_link', function ($termlink, $term, $taxonomy) {
   
    // taxonomy type
    if ('property_type' == $taxonomy) {
        $termlink = trailingslashit(get_home_url()) . 'property/?jsf=jet-engine&tax=property_type:' . $term->term_id; . $anchor . '#here';
    }
    
    // taxonomy city
    if ('property_city' == $taxonomy) {
        $termlink = trailingslashit(get_home_url()) . 'property/?jsf=jet-engine&tax=property_city:' . $term->term_id; . $anchor . '#here';
    }
    
    return $termlink;
}, 10, 3);

You Just need to remove semicolon after $term->term_id so Final code will look like below

add_filter('term_link', function ($termlink, $term, $taxonomy) {
    if ('property_type' == $taxonomy) {
        $termlink = trailingslashit(get_home_url()) . 'property/?jsf=jet-engine&tax=property_type:' . $term->term_id . $anchor . '#here';
    }
    if ('property_city' == $taxonomy) {
        $termlink = trailingslashit(get_home_url()) . 'property/?jsf=jet-engine&tax=property_city:' . $term->term_id . $anchor . '#here';
    }
    return $termlink;
}, 10, 3);