All Collections
Developing with Shifter
How to exclude URLs from the generator's target URLs
How to exclude URLs from the generator's target URLs
Tomohyco Tsunoda avatar
Written by Tomohyco Tsunoda
Updated over a week ago

How to apply

Insert following filter to functions.php on your theme.

Code

add_filter( 'ShifterURLS::CheckURL', function ($correct_link, $link));

Return false to the paths, you want to exclude.

Limitations

  • URLs should be provided or by WordPress.

  • URLs to CSS, JS or other assets are not excluded.

Sample

Sample Code A

Omit URLs that contain /archive/ from the Generator's target URLs.

In this sample, the function expands regular expressions of the given URLs and compares them. Then it returns `false if URLs contain /archive/.

add_filter( 'ShifterURLS::CheckURL', function ($correct_link, $link) { 
// omitting every URLs which contains /archive/ from the Generator's target URLs.
if ( preg_match( '#/archive/#', $link ) ) {
$correct_link = false;
}
return $correct_link;
}, 10, 2);

Did this answer your question?