Skip to Main Content

Related Entry in URL Format with Craft CMS Channel

How to set the url format of a Craft Channel to use an Entries field.

I have a current website build where I have 2 channels. One is for Photographers and the other is for photos. In the photos channel there is an entry field where you select the photographer. For this section I needed the url format to be:

/photographers/firstName-Lastname/{slug} where firstName-LastName was the slug of the related photographer entry. This is relatively simple to do, but how to is not available in the documentation. I found the solution on this stack exchange thread.

In the code below replace fieldHandle with the handle of your related entries field.

    
    
      photographers/{fieldHandle.first().slug}/{slug}
    
  

More Articles You May Like