如何解决分类法重写段符意外字符%2F
我有一个快速的问题需要解释。 我不知道该如何解决。
我用facetwp和jetengine的wordpress创建了一个房地产网站, 我在property_category中创建了分类法
我需要重写段塞并自定义永久链接结构。但效果不理想。 在网址中而不是
/test/property/?_category=apartments
我看到了
/test/property/?_category=%2Fappartements%2F
如何删除这些%2F ?
怎么了?发生什么事了?
更新22/08/2020
这似乎是比我想象的还要复杂的问题?
我必须用图片详细解释所有内容,以便您可以直观地看到问题所在。 我要复制的是使用wpresidence theme和facetwp的jetengine,除分类链接外,其他所有方法都工作正常。
您可以测试他们的网站,并告诉我我不了解的内容。 这似乎是粘贴以修改分类法的代码?
gist.facetwp上也可能有这些代码?
<?php
/** basic output of using facet links instead of taxonomy archive
** change 'my_taxonomy_name','fwp_my_facet_name','http://example.com/page_for_facets/'
** note that if using facetwp_index_row or facetwp_indexer_row_data to change the facetwp_value
** this would not work out of the box
**/
$terms = get_the_terms( get_the_ID(),'my_taxonomy_name' );
if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {
foreach ( $terms AS $term ) {
$name = $term->name;
$link = add_query_arg( 'fwp_my_facet_name',FWP()->helper->safe_value( $term->slug ),'http://example.com/page_for_facets/' );
echo "<a href='$link'>$name</a><br />"; // very basic output of link,change as need
}
}
我不知道该怎么办
更新22/08/2020 18:26
我发现这段代码解决了我的问题,我与之分享。
add_filter('term_link',function ($termlink,$term,$taxonomy) {
if ('property_type' == $taxonomy) {
$termlink = trailingslashit(get_home_url()) . 'property/?_category=' . $term->slug;
}
return $termlink;
},10,3);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。