How to Fix “-2” Added to URL in WordPress

Posted on: May 16th, 2024
By: Tadeo Martinez

This means there is another post, page, product or custom post type with that same URL extension. It might have been created by accident and even if you deleted the post, page, product or custom post type the URL still exists.

Run the following command with WP CLI to find the ID of associated with the duplicate URL.

wp post list --post_type=product --name="conflicting-url" --field=ID

Run the following command to delete that post, page, product or custom post type for good.

wp post delete <post-id> --force

Have any questions or comments? Write them below!


Leave a Reply

Your email address will not be published. Required fields are marked *