Hi @jodurson,
I am not certain if I understand you correctly, but normally, if “Canonical redirect” is turned on in the plugin settings, Permalink Manager will also automatically redirect the native/original permalinks to the new custom permalink set with “Current URI”:
https://permalinkmanager.pro/docs/faq/old-permalinks-redirect/#canonical-redirect-in-permalink-manager
If you are using Permalink Manager Pro, you can copy the “Default URI” and save it as an “Extra redirect”:
https://permalinkmanager.pro/docs/redirects/wordpress-custom-redirects/
Thanks for reply, @mbis!
I’ll try to tell you a little more.
In current development redirects are disabled on my site.
For some Woo product categories I create custom URI’s through the Current URI field. Sometimes it coincides with the Default URI and then there is no problems and not needed to create a 404 on the Default URI.
But when Current URI != Default URI – there go problem: both links exists. Previously, something in the plugin settings allowed us to send 404 from the Default URI.
I can’t remember what these settings were, even through the reverse actions.
-
This reply was modified 2 years, 6 months ago by jodurson.
Hi @jodurson,
Ok, I think I got it. Basically, the problem is that you would like to force 404 on “Default URI” instead of redirecting it to the actual permalink (“Current URI”)?
@mbis, yes!
At least just for all Default URI’s, not taking into the cases of coincidence of Default URI and Current URI.
The default URI is not stored anywhere, it is just generated dynamically in the admin interface. If the Default URI is recognized, it means that they are identical to the native/original permalinks.
Could you try to access a sample product category using its Default URI if Permalink Manager is deactivated?
Edit:
If you would like to force “404” on Default URI product category pages you will need to use an additional code snippet:
function pm_force_404_on_native_permalinks() {
global $wp_query, $pm_query;
// 1. Get the queried object
$object = get_queried_object();
// 2. Use it only if no custom permalink is detected
if(!empty($pm_query['id'])) { return; }
// 3. Use it only for product categories
if(empty($object->taxonomy) || $object->taxonomy !== 'product_cat') { return; }
// 4. Force "404" error page
$wp_query->query = $wp_query->queried_object = $wp_query->queried_object_id = null;
$wp_query->set_404();
status_header(404);
nocache_headers();
$pm_query = '';
}
add_action('wp', 'pm_force_404_on_native_permalinks', 5);
Please paste it to functions.php file in your child theme directory.
-
This reply was modified 2 years, 6 months ago by Maciej Bis.
Thx, @mbis!
Will try this snippet and will return with feedback if you have any questions.