如何在WordPress页面名称之后传递URL参数

huangapple go评论85阅读模式
英文:

how do i pass url parameter after page name in wordpress

问题

我有一个页面的URL localhost://testing/partners,在这里我需要在页面名称后传递参数,如 localhost://testing/partners/category/abcdlocalhost://testing/partners/details/xyz,但当我在页面名称后添加参数时,出现404页面未找到的错误。

而且我也需要获取这些参数。我已经尝试过了,但没有成功。

add_rewrite_rule('^partners/([^/]+)/?', 'index.php?pagename=partners&$matches[1]', 'top');
英文:

I have a page url localhost://testing/partners, here i need to pass parameters after page name like. localhost://testing/partners/category/abcd or localhost://testing/partners/details/xyz
but when i am adding parameter after page name getting error 404 page not found.

and also i need to fetch that parameters. i have tried but its not working.

 add_rewrite_rule( '^partners/([^/]+)/?', 'index.php?pagename=partners&$matches[1]', 'top' );

答案1

得分: 2

如果您想为自定义分类创建文章名称,您可以在WordPress仪表板的永久链接设置中进行这些更改。

设置->永久链接

参考链接:

https://wordpress.org/documentation/article/settings-permalinks-screen/

英文:

@initial

If you are trying to create post names for custom categories, you can make these changes in the Permalink Settings from the WordPress Dashboard.

Settings->Permalinks

如何在WordPress页面名称之后传递URL参数

Reference:

https://wordpress.org/documentation/article/settings-permalinks-screen/

huangapple
  • 本文由 发表于 2023年8月5日 14:23:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76840397.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定