将面包屑链接重定向到特定页面
在我网站的每个页面上,页面内容上方都有面包屑链接。我想要做的是更改链接,以便当它是“主页>事件>示例”时,“事件”链接会将用户重定向到事件页面而不是类别页面。
总之,目前,单击“事件”面包屑链接会将您带到“事件”帖子的类别页面。我希望它将用户带到特定的事件列表页面。
这样做的最佳方法是什么?我最初的想法是编辑“category-3.php”来复制“事件”页面,但有更好的方法吗?我想对站点上面包屑链接中“事件”所在的每个场景执行此操作。
提前致谢。
On each page of my website I have breadcrumb links above the page content. What I want to do is change the link so that when it is 'Home>Events>Example', the 'Events' link will redirect users to an events page instead of a category page.
So in summary, at the minute, clicking the Events breadcrumb link brings you to a category page of Event posts. I want it to instead bring users to a specific Event listings page.
What's the best way of doing this? My initial thought was to edit 'category-3.php' to replicate the Events page, but is there a better way? I want to do this for every scenario across the site where 'Events' is in the breadcrumb links.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果没有看到面包屑的代码,我将不得不做出一些假设。我想象它会在某个地方迭代一个脚本,根据页面结构构建面包屑。如果发现该循环,则可以对其执行 str_replace,同时假设事件属于特定类别,且 URL 始终保持不变。
因此,如果您找到循环并找到保存事件链接的变量,您可以按照以下示例进行操作:
假设原始事件面包屑链接没有更改,这应该可以完成工作。如果您需要进一步帮助,请发布面包屑代码。
Without seeing the code for the breadcrumb I'm going to have to make some assumptions. I imagine it iterates through a script somewhere that builds the breadcrumb based on the page structure. If you find that loop you can do an str_replace on it, also assuming that events pertains to a specific category with a URL that always remains the same.
So if you find the loop and find the variable that holds the link for event you can follow this example:
That should get the job done, again, assuming that the original Events breadcrumb link does not change. If you need further help post the breadcrumb code.