Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a function that creates a page when I create a post (so as to construct parent-child relationship trees).

I'm using the $title of the post to create the page and this also creates a duplicate slug. Is there a way to alter the slug slightly so as to make it unique? How can I assure that the new slug will not interfere with the original post?

share|improve this question

1 Answer

I guess WP automatically appends a number at the end if the slug repeats.

share|improve this answer
I would like to believe that but it simply isn't the case 100% of the time for my site. – AlxVallejo Apr 11 '12 at 21:32
Since you're creating the page manually via PHP rather than using the built in WordPress methods it's probably sidestepping any duplicate name checks. You'll need to check to see if that slug already exists when trying to make the page, then adjust the slug if it is already there. – hereswhatidid Nov 7 '12 at 15:27
Some code samples would greatly help in diagnosing this as well. – hereswhatidid Nov 7 '12 at 15:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.