首页 > 解决方案 > 在 WordPress 中向自定义分类的术语 slug 添加一个词

问题描述

我有一个称为“地方”的分类法,该分类法中的术语 slug 可能类似于:

"domain.com/places/hong-kong/"
"domain.com/places/usa/"

我怎样才能在蛞蝓的第三部分添加一个词,但仍然让它显示地名?

例如,如果要添加单词“place”,它会是这样的:

"domain.com/places/hong-kong-place/"
"domain.com/places/usa-place/"
"domain.com/places/israel-place/"
"domain.com/places/denemark-place/"

或者

"domain.com/places/place-hong-kong/"
"domain.com/places/place-usa/"
"domain.com/places/place-israel/"
"domain.com/places/place-denemark/"

明确一点:我要修改的部分是术语标题部分,而不是分类标题部分。

标签: wordpressurl-rewritingcustom-taxonomyslugtaxonomy-terms

解决方案


将此插件用于自定义永久链接。 https://wordpress.org/plugins/custom-permalinks/

或者您可以使用此代码创建自定义永久链接

function reset_permalinks() {
global $wp_rewrite;
$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
}
add_action( 'init', 'reset_permalinks' );

推荐阅读