0

I'm trying to create a custom post type where there will be a lot of identical post names, but they will have different taxonomy values. Is it possible to define a slug mode where the taxonomy prepends the post name?

Something like this: example.com/[etc.]/taxonomy-postname

2
  • 1
    If I understood correctly, in your case "Posts are differentiated by taxonomy not by name"; it sounds a edge case to me. Can you explain further the situation and use case?
    – cybmeta
    Jun 22, 2016 at 9:59
  • The idea is for a housing plugin where there will be a lot of houses/apartments/etc. with similar numbers, but the project name will be different. There could be project A house 1, Project A house 2, etc. And the Project B house 1, Project B house 2 The name of each post would only be House 1/2, but in order to separate the URL it would be beneficial to have the project name (taxonomy) as part of the slug. Jun 24, 2016 at 11:12

1 Answer 1

0

While I agree with @cybmeta that it sounds like an edge case considering WP, it's a reasonable requirement. And we throw out questions that are too general :-)

I'm sidestepping your exact question a little, as I can see that creating a number of posts and forcing their slugs to be non-unique might be a recipe for future disaster. What do you do to the slugs if you have a House 2 in Project A, a House 2 in Project B and someone changes them both to be in Project B? And House 3 on Project B is never ever really going to need to move to Project D, is it? I've a feeling that a taxonomy isn't the right thing here.

If this was my coding project, I'd define two CPTs for projects and houses, building customisations into the WP admin screens to allow me to assign houses as child posts of projects. A bit like Posts/Pages & their attached Attachments. (I've done something similar in the past for Product Variations/Options but never got the interface right due to lack of time/budget on the job.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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