Skip to content

Past events feed#1189

Merged
mauteri merged 12 commits intoGatherPress:developfrom
jmarx:past-events-feed
Sep 27, 2025
Merged

Past events feed#1189
mauteri merged 12 commits intoGatherPress:developfrom
jmarx:past-events-feed

Conversation

@jmarx
Copy link
Copy Markdown
Collaborator

@jmarx jmarx commented Sep 14, 2025

Description of the Change

Closes #1188

How to test the Change

Test the past events feed:
Visit http://yoursite.com/event/feed/?type=past - should show past events
Visit http://yoursite.com/event/feed/ - should show upcoming events
Test the automatic feed link on past events page:
Configure a past events archive page in GatherPress Settings
Visit that page and check the RSS feed link in page source
Verify the link includes ?type=past parameter
Test edge cases:
?type=invalid should default to upcoming events
?type= should default to upcoming events

Changelog Entry

Adds support for past events RSS feeds via ?type=past parameter. When viewing the past events archive page, the RSS feed link automatically includes this parameter.
Added - Past events RSS feed support with ?type=past parameter

Credits

Props @jmarx

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@what-the-diff
Copy link
Copy Markdown

what-the-diff bot commented Sep 14, 2025

PR Summary

  • New Query Parameter Addition
    A new parameter, gatherpress_events_query, is now available. This is primarily used to improve the handling of event query situations.

  • Event Feed Handling Improvement
    The method used to handle event feeds has been updated. This enhancement now allows for the inclusion of a ?type=past parameter, which helps retrieve historical events.

  • Feed Link Modification
    A method, modify_feed_link_for_past_events, was introduced to change feed links. Specifically, it adds type=past to the feed link if the current query is for past events, making it easier to access historical data.

  • More Comprehensive Unit Tests
    Additional tests have been incorporated. These tests target the enhanced handling of the event feed query using the type parameter and check that the method modify_feed_link_for_past_events, truly modifies feed links to fetch past events. This contributes to robustness and reliability of the software.

@jmarx jmarx marked this pull request as ready for review September 14, 2025 14:46
@jmarx jmarx requested a review from mauteri September 14, 2025 14:46
add_action( 'pre_get_posts', array( $this, 'handle_events_feed_query' ) );

// Modify feed link for past events page.
add_filter( 'post_type_archive_feed_link', array( $this, 'modify_feed_link_for_past_events' ), 10, 1 );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need 10, 1 as those are defaults.

@@ -189,8 +189,9 @@ public function prepare_event_query_before_execution( WP_Query $query ): void {
if ( $page->id === $query->queried_object_id ) {
$query->set( 'post_type', 'gatherpress_event' );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe bring this down with the other ->set on line 194 to keep like things together.

$query->set( 'gatherpress_events_query', 'upcoming' );

// Check for type parameter to determine if we want past or upcoming events.
$event_type = 'upcoming'; // Default to upcoming events.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a line break here for readability.


// Check for type parameter to determine if we want past or upcoming events.
$event_type = 'upcoming'; // Default to upcoming events.
if ( isset( $_GET['type'] ) && 'past' === sanitize_text_field( wp_unslash( $_GET['type'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Public feed URL parameter, nonce not required.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if ( 
    isset( $_GET['type'] ) && 
    'past' === sanitize_text_field( wp_unslash( $_GET['type'] ) ) 
) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Public feed URL parameter, nonce not required.

multiline for readability.

global $wp_query;

// Check if we're on the past events page by looking for the gatherpress_events_query var.
if ( isset( $wp_query->query_vars['gatherpress_events_query'] ) && 'past' === $wp_query->query_vars['gatherpress_events_query'] ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, multiline for readability.

$page_id = $query->queried_object_id;
$events_query = $key;
$query->set( 'post_type', 'gatherpress_event' );
$query->set( 'gatherpress_events_query', $key );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change to gatherpress_event_query

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mauteri I just realized we can't make this change without changing a bunch of things. I feel like we should keep it plural for now. Or I will get to that change later in the week where I can test the query loop block which uses this. Up to you.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mauteri Just to follow up on this. I reverted everything back to plural for now because it was indeed messing up the Event Query block. I am going to troubleshoot and try to fix that(simple search and replace/npm run build did not seem to do the trick). But for now, I am going to revert this change so the pr is in a working state. But I'll keep working on it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mauteri OK, it should be all set now. Please review again.

@jmarx jmarx requested a review from mauteri September 21, 2025 15:14
@github-actions
Copy link
Copy Markdown
Contributor

Preview changes with Playground

You can preview the recent changes for PR#1189 with the following PHP versions:

PHP Version 8.3

PHP Version 7.4

Download .zip with build changes

Made with 💙 from GatherPress & a little bit of WordPress Playground. Changes will not persist between sessions.

@jmarx jmarx requested a review from mauteri September 23, 2025 00:52
@carstingaxion
Copy link
Copy Markdown
Collaborator

Hello @jmarx ,

Could you write a short explanation, for what kind of use cases such a feature would be needed?
Thanks.

@mauteri mauteri merged commit 944f63e into GatherPress:develop Sep 27, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add past events RSS feed support

3 participants