我试图在我的代码中放置一个锚使链接指向#here
比如
mysite/属性/? jsf = jet-engine&税收= property_type: 9#这里
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);
你只需要去掉
$term->term_id
后面的分号因此最终代码将如下所示
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);