wordpress - 在 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/"
明确一点:我要修改的部分是术语标题部分,而不是分类标题部分。
解决方案
将此插件用于自定义永久链接。 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' );
推荐阅读
- python - Python C API,最佳实践
- powershell - 通过 Powershell 在 DC 上编辑/添加 GPO
- python - 使用不同的规则从多个列在 df 中创建一个新的 Pandas 列
- tensorflow - 如何优化预训练的 TF2.0 模型进行推理
- python - 当其他进程请求大量内存时,进程使用的内存减少?
- html - 删除按钮之间的间距
- reactjs - 对一组对象使用 useMemo/React.memo 以防止在编辑其中一个对象后重新渲染的最佳方法?
- c# - 方法的类型签名与 PInvoke 不兼容 .net framework 4.8
- angular - 使用 Angular 和 PrimeNG 的日期格式
- css - 如何让我的侧边菜单栏自动占据整个剩余空间