feat: add option to ignore specific post types in redirection checks#4041
Open
saurab1996 wants to merge 5 commits intojohngodley:trunkfrom
Open
feat: add option to ignore specific post types in redirection checks#4041saurab1996 wants to merge 5 commits intojohngodley:trunkfrom
saurab1996 wants to merge 5 commits intojohngodley:trunkfrom
Conversation
Owner
|
I know this is a while ago, but why do you need to ignore post types? |
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request adds support for ignoring selected WordPress post types from Redirection checks.
Changes
ignore_posttypesis_ignore_posttypes()) now checks if the current post type is in the ignored list and skips processing if soWhy
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
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.