【发布时间】:2017-03-27 17:22:23
【问题描述】:
我有 wordpress 自定义模板页面 test.php,我想在其中通过 url 传递变量,
http://localhost/wordpress/test?date=2017&postid=11&title=some-title
以这种格式,
http://localhost/wordpress/test/2017/11/some-title
并从 url 中获取参数。
我已关注此link,但无法产生我想要的结果。
还有其他方法可以达到我提到的预期结果吗???我是 wordpress 主题开发的新手。
【问题讨论】:
-
会对“为什么”感兴趣。鉴于我对 WP 有一些经验,并且根本不需要这样做。当然,您可能有原因,或者您可能错过了实现最终结果的更简单方法。
-
您可以使用您的 Web 服务器(apache 或 nginx)重写规则来重写查询参数的路径。这样用户将看到第二种格式,但在 php 中,您将使用第一种格式和查询参数,并使用 wordpress 中的普通
get_query_var
标签: php wordpress wordpress-theming