Avatar of ChrisGreenhough
ChrisGreenhough

asked on 

Why is WordPress creating permalinks with -2 at the end when no duplicate exists?

Working on a WordPress site that is pulling post data from a third party system via an externally triggered Cron. Everything seems to be working absolutely fine, except that as posts are being created each post slug has -2 appended as if there were already a post with the same name - except there isn't. This doesn't always happen, however. If I zero the post tables in the db and run the custom post import plugin, everything is fine to begin with.

I had a feeling it might be something to do with being logged into the back end when the Cron task runs, but I can't prove this and am not sure where else to look for the issue or the solution.

Tried adding "if ( ! current_user_can( 'edit_posts' ) )" before the import function runs, but this didn't seem to cure it. Not sure how to proceed so any help appreciated.

Many thanks.

P.S. I'm not really a WordPress developer, more a designer who dabbles :)
WordPress

Avatar of undefined
Last Comment
ChrisGreenhough
SOLUTION
Avatar of Jason C. Levine
Jason C. Levine
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
ASKER CERTIFIED SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of ChrisGreenhough
ChrisGreenhough

ASKER

Thanks Jason and William for the valuable advice. I've spent endless hours coaxing this custom plugin to do what is required, even though I'm not actually a programmer and the third party that supplied it is a full time developer but gave us a crippled piece of software... Anyway, I won't get into that :) I appreciate the feedback. Rather than spend more time in the code, I'm going to try this plugin (https://wordpress.org/plugins/no-slug-conflicts-with-trash/) and hope that resolves it. I would never have thought to look for that plugin without the insights you offered, however, so my sincere thanks to you both.

Regards,
Chris G.
Avatar of ChrisGreenhough

ASKER

Very helpful and a quick response to my need for assistance :)
WordPress
WordPress

WordPress is a free and open-source content management system (CMS) based on PHP and MySQL for creating websites and blogs. Features include a plugin architecture, a template system and strong management, customization and search systems; through its dynamic presentation of content, webmasters have the flexibility to create websites easily.

11K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo