Skip to content

Fix is_archive() checks#56

Merged
nate-allen merged 1 commit intoa8cteam51:trunkfrom
happyprime:fix/archive-checks
Dec 10, 2025
Merged

Fix is_archive() checks#56
nate-allen merged 1 commit intoa8cteam51:trunkfrom
happyprime:fix/archive-checks

Conversation

@philcable
Copy link
Contributor

@philcable philcable commented Dec 10, 2025

Changes proposed in this Pull Request

  • Replace is_archive( 'se-event-category' ) with is_tax( 'se-event-category' ), and is_archive( 'se-event-date' ) with is_post_type_archive( 'se-event-date' ).

The is_archive() function doesn't accept any parameters, so it's returning true for any archive view.

Mentions https://github.com/a8cteam51/bfi/issues/812

Summary by CodeRabbit

  • Bug Fixes
    • Fixed template detection for event category and event date archive pages to ensure proper page rendering.

✏️ Tip: You can customize this high-level summary in your review settings.

The `is_archive()` function doesn't accept any parameters, so it's returning `true` for any archive view.
@coderabbitai
Copy link

coderabbitai bot commented Dec 10, 2025

Walkthrough

The changes update archive detection logic in the template loader class. Specifically, the detection for event category archives is changed from generic archive detection to taxonomy-specific detection, and the detection for event date archives is changed from generic archives to post type archive detection. These modifications refine how the template system identifies and handles different types of event-related archive pages.

Possibly related PRs

  • doing it wrong and more tempalte issues #32: Modifies SE_Template_Loader's template detection logic for se-event-category and event archive checks, using different conditional methods for archive and post-type detection.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: fixing incorrect is_archive() function calls. It is concise, clear, and accurately summarizes the primary objective of the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/classes/class-se-template-loader.php (1)

74-76: Critical: Early return blocks 'se-event-date' handling.

Line 74's early return only checks for 'se-event' post type, but the code below (lines 83-104 and 108-120) also handles 'se-event-date' content. This means singular 'se-event-date' posts and 'se-event-date' post type archives will return early with the default template, preventing the custom template logic from executing.

Apply this diff to allow 'se-event-date' content through:

-	if ( ! is_singular( 'se-event' ) && ! is_post_type_archive( 'se-event' ) ) {
+	if ( ! is_singular( array( 'se-event', 'se-event-date' ) ) && ! is_post_type_archive( array( 'se-event', 'se-event-date' ) ) ) {
 		return $template;
 	}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0adecec and d25c3db.

📒 Files selected for processing (1)
  • src/classes/class-se-template-loader.php (2 hunks)
🔇 Additional comments (1)
src/classes/class-se-template-loader.php (1)

59-59: Correct fix for taxonomy archive detection.

The change from is_archive('se-event-category') to is_tax('se-event-category') is correct. The is_archive() function doesn't accept parameters, so the old code was always returning true for any archive page. Using is_tax() properly targets the specific taxonomy archive.

// Determine if standard se-event archive templates are available in the theme
// before replacing with the custom template in this plugin.
if ( is_archive( 'se-event-date' ) ) {
if ( is_post_type_archive( 'se-event-date' ) ) {
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Correct fix for post type archive detection.

The change from is_archive('se-event-date') to is_post_type_archive('se-event-date') is correct. However, this code will not execute due to the early return at line 74 blocking 'se-event-date' content.

🤖 Prompt for AI Agents
In src/classes/class-se-template-loader.php around lines 74 and 108, the new
is_post_type_archive('se-event-date') check at line 108 is correct but never
reached because the early return at line 74 exits for the same requests; update
the early return so it does not short-circuit se-event-date requests.
Concretely, modify the condition at line 74 to exclude se-event-date (or add an
explicit exception) — i.e., only return early when the request is not a
se-event-date post type/archive (use is_post_type_archive('se-event-date')
and/or is_singular('se-event-date') to gate the exception) so the subsequent
is_post_type_archive('se-event-date') branch can execute.

@nate-allen nate-allen merged commit 1f2d158 into a8cteam51:trunk Dec 10, 2025
7 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.

2 participants