1

I have a sports website that will have very similar slugs:

http://example.com/match/teamA-vs-teamB

Sooner than later, teams A and B will play again, and the slugs will repeat themselves:

http://example.com/match/teamA-vs-teamB-1

The solution I found was to prepend a date to the match, making it look like this:

http://example.com/match/2017-01-31/teamA-vs-teamB

This will guarantee I have unique slugs and is also user friendly.

I tried to change "rewrite" option on register_post_type without success, because whatever I add there will be the same for all "match" post types.

How can I append the scheduled post date to the slug?

2
  • How about creating a custom post type with a taxonomy? Where the CP is match and its tax. is teamA vs teamB
    – klewis
    Feb 1 '17 at 3:16
  • There's a lot of related questions around this. I think this answer stackoverflow.com/a/23702560/450127 (or a modification of it) will do what you want.
    – Ian Dunn
    Jan 20 '18 at 20:29
1

I ended up using Custom Post Type Permalinks plugin

Works pretty well:

Append date to custom post type wordpress

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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