• Hello WordPress Support Team,
    I am experiencing an issue with my WordPress site where the slugs of my pages are changing unexpectedly and without my intervention.


    Technical Details
    ? WordPress Version: 6.7.1
    ? Active Plugins: Rank Math (Version 1.0.234), Elementor

    Problem Description
    I have noticed that the slugs of my pages are being altered randomly. Specifically:
    ? The slug sometimes changes to that of the homepage.
    ? Suffixes like “-2-2-2” are being appended to the slugs.
    ? In some cases, the slug is replaced with that of another existing page.

    Behavior
    ? The changes occur unpredictably.
    ? They happen when I edit or save a page.
    ? There are no intentional actions on my part that seem to trigger these changes.

    Actions Taken
    ? I have checked the permalink settings in WordPress.
    ? I have updated both WordPress and all plugins to their latest versions.
    ? I have not made any manual changes to the slugs.

    I would appreciate any assistance you can provide in diagnosing and resolving this issue.
    Thank you for your help!
Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @cbast77,
    ?
    Thank you for contacting Rank Math support, and sorry for any inconvenience that might have been caused due to that.
    ?
    The number is added if there are other URLs with the same slug. Please check your URLs as well if it’s getting duplicated.
    ?
    If none, then this happens when the?Redirect Attachments?option is enabled on your site, and you have a media or attachment URL with the same slug.
    ?
    If that is the case, you can re-upload the media with a different file name or at least rename the attachment URL to a different slug to avoid getting the?-2?or?-3?in the last part of the URL.
    ?
    Looking forward to helping you.

    Thread Starter Sébastien TEBOUL

    (@cbast77)

    Hello Rank Math Support Team,
    I appreciate your previous response, but I believe there might be a misunderstanding regarding my issue. I am experiencing a problem where new slugs are being created unexpectedly, resembling duplicates with suffixes like “-2-2-2”, but without any actual redirection being set up.
    Technical Details
    ? WordPress Version: 6.7.1
    ? Rank Math Version: 1.0.234
    ? Additional Plugins: Elementor
    Problem Description
    The issue is not about duplicated URLs or redirections. Instead, new slugs are being created automatically with suffixes such as “-2-2-2”. This occurs randomly and seems to be linked to the schema settings rather than any existing URL conflicts or media attachments.
    What I’ve Checked
    ? There are no duplicate URLs or media attachments with the same slug.
    ? The “Redirect Attachments” option is not causing this issue, as there are no attachment URLs with these slugs.
    ? My permalink structure is correctly configured.
    ? I suspect a schema-related setting might be influencing this behavior.
    Request for Assistance
    Could you please investigate whether there might be an issue with how Rank Math handles schema settings that could lead to the creation of these unexpected slugs? Any guidance on resolving this issue would be greatly appreciated.
    Thank you for your help!
    Best regards,

    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @cbast77,

    Our schema module doesn’t interact with the permalink and our plugin doesn’t have any features to modify the permalinks at all. When it comes to URL modification, our plugin can only remove the base of a permalink.

    Can you please share some more details about how you discovered that our schema is causing the conflict with the slug changes? If there are some steps you can share to replicate the issue, please share it here so we can try this out from our end as we never experienced this issue with our Schema module.

    Looking forward to hearing back from you.

    Thread Starter Sébastien TEBOUL

    (@cbast77)

    Hello,

    I have opened a support ticket with Rank Math (#935983). Is it the same support team ?

    I can share my website admin access so you can investigate this issue that has occurred on all recent websites.

    Best regards,

    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @cbast77,
    ?
    Our development team is investigating the issue on your site and will get back to you soon with an update.
    ?
    Thank you.

    Hey, did you get a solution to this? I have the same problem..

    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @tatu13524,
    ?
    If you are also experiencing this we would recommend getting in touch with our developers by following the steps here:?https://www.ads-software.com/support/topic/attention-read-this-before-posting/
    ?
    Thank you.

    I’m having the same exact issue. Have you guys found an explanation?

    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @psssst,
    ?
    Thank you for reaching out. Our development team is actively investigating this issue based on reports from other users. If you’re experiencing the same, we recommend contacting the dev. team at [email protected] so we can promptly reply to your queries.
    ?
    We appreciate your patience.

    What was the resolution for this? I have been experiencing this exact same issue for months now. I have reached out to RankMath and they have not sufficiently responded.

    Thread Starter Sébastien TEBOUL

    (@cbast77)

    Hello,

    The support team indicated that this issue couldn’t be caused by the Rank Math plugin.

    To investigate this further, I’ve developed a PHP tracking solution using ChatGPT that monitors all slug modifications. I’ve implemented this through a Hello Child Theme by adding the code to the functions file. The tracking now generates log entries in this format:Copy

    [2025-01-07 14:35:10] Attempted slug modification by the 'seo-plugin' for the page 'Ma Page Exemple' (ID: 123): ma-page-exemple => nouvelle-page

    The tracking is working successfully. I can share the PHP code if you’d like to review it.

    Best regards,

    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @cbast77,
    ?
    We would love to review the code you created to make sure it’s reporting the slug changes accurately. If you could share it we can get a closer look.
    ?
    Thank you.

    Thread Starter Sébastien TEBOUL

    (@cbast77)

    My code :

    if ( ! function_exists( ‘child_prevent_plugin_slug_modification’ ) ) {
    function child_prevent_plugin_slug_modification( $data, $postarr ) {
    // Log pour debug initial
    error_log(‘Fonction exécutée – ‘ . current_time(‘Y-m-d H:i:s’), 3, WP_CONTENT_DIR . ‘/debug_slug.log’);

        // Vérifie les conditions de base
    if ( ! isset( $data['post_type'] ) || ! isset( $postarr['ID'] ) ) {
    return $data;
    }

    // Ne s'applique qu'aux pages
    if ( 'page' !== $data['post_type'] ) {
    return $data;
    }

    $original_post = get_post( $postarr['ID'] );
    if ( ! $original_post ) {
    return $data;
    }

    // Log pour vérifier si on arrive jusqu'ici
    error_log(
    sprintf(
    "Vérification de modification - Page: %s, Original: %s, Nouveau: %s\n",
    $original_post->post_title,
    $original_post->post_name,
    isset($data['post_name']) ? $data['post_name'] : 'non défini'
    ),
    3,
    WP_CONTENT_DIR . '/debug_slug.log'
    );

    // Vérifie si le slug a été modifié
    if ( ! empty( $data['post_name'] ) && $data['post_name'] !== $original_post->post_name ) {
    // Détecte la source de la modification
    $backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS );
    $source = 'Interface utilisateur';
    $is_plugin = false;

    // Analyse plus détaillée du backtrace
    foreach ( $backtrace as $trace ) {
    if ( isset( $trace['file'] ) ) {
    if ( strpos( $trace['file'], 'wp-content/plugins' ) !== false ) {
    $source = 'Plugin: ' . basename( dirname( $trace['file'] ) );
    $is_plugin = true;
    } elseif ( strpos( $trace['file'], 'wp-includes' ) !== false || strpos( $trace['file'], 'wp-admin' ) !== false ) {
    $source = 'WordPress Core: ' . basename( $trace['file'] );
    }
    }
    }

    // Informations utilisateur
    $user = wp_get_current_user();
    $user_info = $user->ID ? $user->user_login : 'Système';

    // Log toutes les tentatives de modification
    $log_message = sprintf(
    "[%s] Type: %s - Utilisateur: %s - Source: %s - Page: '%s' (ID: %d) - Modification: %s => %s\n",
    current_time( 'Y-m-d H:i:s' ),
    ($is_plugin ? 'AUTOMATIQUE' : 'MANUEL'),
    $user_info,
    $source,
    sanitize_text_field( $original_post->post_title ),
    absint( $postarr['ID'] ),
    sanitize_text_field( $original_post->post_name ),
    sanitize_text_field( $data['post_name'] )
    );

    error_log( $log_message, 3, WP_CONTENT_DIR . '/slug_modifications.log' );

    // Bloque uniquement les modifications automatiques par les plugins
    if ( $is_plugin ) {
    $data['post_name'] = $original_post->post_name;
    }
    }

    return $data;
    }
    add_filter( 'wp_insert_post_data', 'child_prevent_plugin_slug_modification', 999, 2 );

    }
Viewing 13 replies - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.