I'm trying to place an anchor in my code so that the links point to #here
for exemple
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);
it seems to me that it must be .$anchor. '#here';
but it seems this is not the right way..(PHP fatal error)
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);