WordPress 插件帮助

发布于 2024-10-06 05:20:29 字数 628 浏览 1 评论 0原文

我创建了一个插件,通过 url 传递变量。该变量是数据库中项目的 ID。在数据库中,我有一个存储的搜索引擎友好字段,我可以用它来设置 url,但不知道如何操作。数据库的示例:

id     sef           name
1      dogs-name     Dog's Name

现在,当我在 url 中传递变量时,我通过以下方式传递它:

<a href="current-url/?id=<?php echo $id;?>">Link</a>

我想做的是这样的:

<a href="current-url/<?php echo $sef;?>">Link</a>

这将产生一个更好的 url。然而,当我这样做时,它不起作用,因为 WordPress 将我发送到 404 页面。有谁知道这是否可能,并且可以给我一个如何做到这一点的例子吗?我研究了漂亮的永久链接的东西,但只找到了如何重写在 WordPress 中创建的 url,而不是来自创建的插件。有没有办法可以通过wordpress添加一个变量进行替换以进行重写?

任何帮助表示赞赏。

I have created a plugin where I am passing a variable through the url. The variable is the id of an item from the database. In the database I have a stored search engine friendly field that I could use to set the url but am lost as to how to do it. Example of the db:

id     sef           name
1      dogs-name     Dog's Name

Now when I am passing the variable in the url I am passing it by doing:

<a href="current-url/?id=<?php echo $id;?>">Link</a>

What I would like to do is something like this:

<a href="current-url/<?php echo $sef;?>">Link</a>

This would make for a much nicer url. However when I do that it doesnt work because wordpress is sending me to the 404 page. Does anyone know if this is possible and can give me an example of how to do it? I looked into the pretty permalinks stuff but only found how to rewrite the urls made in wordpress and not coming from a plugin that is created. Is there a way to possibly add a variable for replacement through wordpress to be rewritten?

Any help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文