Solved ugly, but works. General form of the filter:
<?php
add_filter('term_link', function ($termlink, $term, $taxonomy) {
if ('CPT-TAXONOMY-NAME' == $taxonomy) {
$termlink = trailingslashit(get_home_url()) . '?FACETWP-FACET-NAME=' . $term->slug;
}
return $termlink;
}, 10, 3);
The function in fuctions.php:
<?php
function list_hierarchical_terms($taxonomy) {
global $post;
$terms = wp_get_post_terms( $post->ID, $taxonomy, array( "fields" => "ids" ) );
if( $terms ) {
echo '<?ul>';
$terms = trim( implode( ',', (array) $terms ), ' ,' );
wp_list_categories( 'title_li=&taxonomy=' . $taxonomy . '&include=' . $terms );
echo '<?/ul>';
}
}
Now I don't know how to write it simpler. The functions for filter in functions.php:
<?php
function termlink_transformation_freuciv_post_type($termlink, $term, $taxonomy)
{
if ('freuciv_post_type' == $taxonomy) {
$termlink = trailingslashit(get_home_url()) . '?fwp_typ=' . $term->slug;
}
return $termlink;
}
function termlink_transformation_category($termlink, $term, $taxonomy)
{
if ('category' == $taxonomy) {
$termlink = trailingslashit(get_home_url()) . '?fwp_categories=' . $term->slug;
}
return $termlink;
}
function termlink_transformation_hierarchical_tags($termlink, $term, $taxonomy)
{
if ('hierarchical_tags' == $taxonomy) {
$termlink = trailingslashit(get_home_url()) . '?fwp_tags=' . $term->slug;
}
return $termlink;
}
And in template-part:
<?php
add_filter('term_link', 'termlink_transformation_freuciv_post_type', 10, 3);
list_hierarchical_terms('freuciv_post_type', '<h5 style="margin-bottom: 5px">Typ: </h5>');
remove_filter( 'term_link', 'termlink_transformation_freuciv_post_type', 10 );
add_filter('term_link', 'termlink_transformation_category', 10, 3);
list_hierarchical_terms('category', '<h5 style="margin-bottom: 5px; margin-top: 10px;">Kategorien: </h5>');
remove_filter( 'term_link', 'termlink_transformation_category', 10 );
add_filter('term_link', 'termlink_transformation_hierarchical_tags', 10, 3);
list_hierarchical_terms('hierarchical_tags', '<h5 style="margin-bottom: 5px; margin-top: 10px;">Tags: </h5>');
remove_filter( 'term_link', 'termlink_transformation_hierarchical_tags', 10 );
There's too much repetition here. I have no idea how to simplify it.