5

I'd like to make the Entry URL format of a channel look like this: /news/2015/06/my-slug-here

What would I need to enter into the Entry URL Format field in order to do this?

The closest I could manage was this:

news/{postDate|date("Y")}/{slug}

But that only outputs this: /news/2015/my-slug-here

Thanks for any help.

7

You're close! For the month part you need postDate|date("m") (this page has the php date formats).

news/{postDate|date("Y")}/{postDate|date("m")}/{slug}
  • 5
    Correct me if I'm wrong, but wouldn't this also work? news/{postDate|date("Y/m")}/{slug} ... You'd put the slash inside the date format, so it won't have to parse postDate twice. – Lindsey D Jun 13 '15 at 6:22
  • Thanks Marion, that worked great. Lindsey's suggestion worked too, thanks. – Stephen Jun 13 '15 at 15:06
  • @Lindsey Hadn't thought of that, but nice improvement. – Marion Newlevant Jun 13 '15 at 21:59

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.