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

本文标签: