Reserve a URL prefix for your plugin
For a plugin that serves its own pages under a top-level segment, like /shop/{slug}. Podcasters choose a show prefix and an episode prefix under Settings → Permalinks. If one of them chooses your segment, every one of your URLs starts resolving as an episode. Reserving the segment makes Benecaster refuse it, with the same reserved word error it gives for wp-admin.
- You can only add. Benecaster’s own reserved words are merged back in after your filter runs, so removing one does nothing. If you need a word core reserves, rename your route.
- The reservation only exists while your plugin is active. A podcaster who set the prefix before installing your plugin already has it stored, and the filter can’t undo that. When your plugin activates, check whether its routes answer, and tell the podcaster to change their permalink prefix if they don’t, rather than failing silently.
- Return lowercase values. They are lowercased and trimmed for you, but don’t rely on that to fix a typo.
go is already reserved for the Outlinks add-on’s links, for exactly the before-install reason above.
Code
<?php
add_filter( 'benecaster_reserved_permalink_prefixes', function ( array $prefixes ): array {
$prefixes[] = 'shop'; // my-addon serves /shop/{slug}
return $prefixes;
} );
Hooks Used
Need this built rather than just documented? See our services →