customization - Is it possible to create 2 unique titles for an Events custom post type: Upcoming Events and Past Events?

I've been trying and failing at trying diff code snippets and searching online for something that works. Posted on

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
Add a comment  | 

1 Answer 1

Reset to default 0

Try 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; ?>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744754467a4591796.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信