Skip to content

Comments

feat: add option to ignore specific post types in redirection checks#4041

Open
saurab1996 wants to merge 5 commits intojohngodley:trunkfrom
saurab1996:feat/ignore-post-types
Open

feat: add option to ignore specific post types in redirection checks#4041
saurab1996 wants to merge 5 commits intojohngodley:trunkfrom
saurab1996:feat/ignore-post-types

Conversation

@saurab1996
Copy link

Description

This pull request adds support for ignoring selected WordPress post types from Redirection checks.

Changes

  • Added a new plugin option: ignore_posttypes
  • Added UI on the Options page to select one or more post types to ignore
  • Backend logic (is_ignore_posttypes()) now checks if the current post type is in the ignored list and skips processing if so

Why

Some sites (e.g., WooCommerce or sites with custom post types) require excluding specific post types from being handled by Redirection to avoid conflicts with their own URL handling.

Additionally, ignoring certain post types can improve performance by skipping Redirection’s database queries and rule checks for requests that don’t need redirection.

How to test

  1. Go to Redirection > Options > Ignore Post Types
  2. Select one or more post types and save
  3. Requests to those post types’ URLs no longer trigger Redirection

Notes

This feature relies on url_to_postid() and get_post_type() to determine the current request’s post type, and assumes pretty permalinks are enabled.

@johngodley
Copy link
Owner

I know this is a while ago, but why do you need to ignore post types?

@saurab1996
Copy link
Author

Hi @johngodley, thanks for taking a look!

In general, not all post types need to participate in redirect logic. Running redirect checks universally can introduce unnecessary database queries without any functional benefit.

In setups like ours, certain post types intentionally opt out of this logic to keep redirect processing focused and efficient for content where it actually matters.

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