admin管理员组文章数量:1390718
I've been trying and failing at trying diff code snippets and searching online for something that works. Posted on the more general forum but saw recommendations to post WP questions on this forum.
I'm customizing a theme that has a Events section as a Post type.
The request is to have one page for Upcoming Events and another for Past Events. There is a way to filter Past Events using website//events/?period=past&order=desc so I've set up the pages and nav menu that way. But both pages have the same title "Events" which can be confusing to the user.
I contacted the theme creator to ask if there's a way to change the titles and was told it's still technically one page so it can only have one title. Is there a workaround so that one page can say "Upcoming Events" and the filtered archive page to say "Past Events"? There are two php files, the archive-header.php and archive-layout.php (screenshots attached). Apologies, my understanding of php is very limited (though learning) and would appreciate any insight or recs. thank you
I've been trying and failing at trying diff code snippets and searching online for something that works. Posted on the more general forum but saw recommendations to post WP questions on this forum.
I'm customizing a theme that has a Events section as a Post type.
The request is to have one page for Upcoming Events and another for Past Events. There is a way to filter Past Events using website//events/?period=past&order=desc so I've set up the pages and nav menu that way. But both pages have the same title "Events" which can be confusing to the user.
I contacted the theme creator to ask if there's a way to change the titles and was told it's still technically one page so it can only have one title. Is there a workaround so that one page can say "Upcoming Events" and the filtered archive page to say "Past Events"? There are two php files, the archive-header.php and archive-layout.php (screenshots attached). Apologies, my understanding of php is very limited (though learning) and would appreciate any insight or recs. thank you
Share Improve this question asked Feb 12, 2020 at 16:10 user1102824user1102824 11 bronze badge
1 Answer
Reset to default 0Try this: in archive-header.php
line 8 - 10 by interecepting the variable "period=past" or ( I guess) "period = future" of current URL
<?php else :
if( !empty($_GET['period'] ) && $_GET['period'] == 'past')
{
echo "Past Events";
}
elseif( !empty($_GET['period'] ) && $_GET['period'] == 'future' /*or whatever*/){
echo "Upcoming Events";
}
else{
echo esc_html(lsvr_pressville_get_event_archive_title());//the default output of your theme function
}
endif; ?>
本文标签:
版权声明:本文标题:customization - Is it possible to create 2 unique titles for an Events custom post type: Upcoming Events and Past Events? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744754466a2623377.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论