admin管理员组文章数量:1303448
I have set template taxonomy-event_type.php
which displays just right on http://localhost:8000/types/<type_name>/
.
What I need now is to:
- either redirect when user lands on
http://localhost:8000
to this page, - or use this template with (what wouldn't be greatest, as i'm checking the url and setting navigation items as active according to the url)
So something like (PSEUDOCODE):
if is_home():
redirect('types/type1')
or
use_template('taxonomy-event_type','type1');
is it possible?
I have set template taxonomy-event_type.php
which displays just right on http://localhost:8000/types/<type_name>/
.
What I need now is to:
- either redirect when user lands on
http://localhost:8000
to this page, - or use this template with (what wouldn't be greatest, as i'm checking the url and setting navigation items as active according to the url)
So something like (PSEUDOCODE):
if is_home():
redirect('types/type1')
or
use_template('taxonomy-event_type','type1');
is it possible?
Share Improve this question edited Mar 20, 2021 at 21:40 MCFreddie777 asked Mar 20, 2021 at 21:19 MCFreddie777MCFreddie777 1012 bronze badges 1- Note that the template doesn't determine the posts that get shown, so if you did load that template on the homepage, it would be the same posts you saw on the homepage before but in that template, not the posts from a particular term. URL creates query -> query fetches posts -> query + posts determines template to load – Tom J Nowell ♦ Commented Mar 20, 2021 at 23:26
1 Answer
Reset to default 0Found a solution:
// redirect on homepage to taxonomy
add_action("template_redirect", function() {
if (is_front_page()) {
return wp_redirect(get_term_link('type1', 'event_type'));
}
});
本文标签: redirectHow to show taxonomy on front page
版权声明:本文标题:redirect - How to show taxonomy on front page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741665713a2391295.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论