Title: Returning field slug
Last modified: August 22, 2016

---

# Returning field slug

 *  Resolved [MarkPGray](https://wordpress.org/support/users/markpgray/)
 * (@markpgray)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/returning-field-slug/)
 * I’m trying to display the field slug but can’t figure it out. When I try and 
   use ‘name’ it actually returns the field’s label rather than the slug name. I’m
   using ACF and a flexible content loop. Here’s what I want…
 * `<h1 id="[field_slug_here]">[sub field="mpg_section_title"]</h1>`
 * Hope this makes sense.
 * [https://wordpress.org/plugins/custom-content-shortcode/](https://wordpress.org/plugins/custom-content-shortcode/)

Viewing 10 replies - 1 through 10 (of 10 total)

 *  [Julie](https://wordpress.org/support/users/habannah/)
 * (@habannah)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/returning-field-slug/#post-5325367)
 * I don’t use ACF so I hope I’m not leading you astray, but I don’t think there’s
   actually a parameter to display the slug. Still, you could do it using the pass
   shortcode:
 *     ```
       [pass field="field_slug_here"]
       <h1 id="{FIELD}">[sub field="mpg_section_title"]</h1>
       [/pass]
       ```
   
 * Something along those lines should work… I hope this helps!
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/returning-field-slug/#post-5325368)
 * What type of field are you trying to display, like a radio/select/checkbox – 
   something that returns a slug or label as value? You can try the general parameter`
   out="slug"`, but it depends if it’s supported or not.
 * I’m currently working on an update of all plugin modules, and plan to improve
   the ACF shortcodes also. I’ll make a note to look at displaying value slugs for
   suitable field types.
 *  Thread Starter [MarkPGray](https://wordpress.org/support/users/markpgray/)
 * (@markpgray)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/returning-field-slug/#post-5325371)
 * Hmmm, I realise my question was not very clear, sorry about that.
 * I have a ‘text’ field and want retrieve its name (slug).
 * E.g. If field name (slug) is “mpg_section_title”, I would like to use this value.
 * Hope this is clearer?
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/returning-field-slug/#post-5325374)
 * I see, the _field_ slug, not the slug of its value. Hmm..how are you getting 
   the field label to display?
 * To be honest, I haven’t worked with the flexible content field in some time, 
   so I had to set up a test page to fully explore what is possible and what is 
   not.
 * From what I see, it seems the label and slug of the field _value_ is possible
   to display, but not slug of the field itself. Since you’re manually specifying
   it for [sub], couldn’t you do the same for `<a id="..">`? Or is there a reason
   it needs to be dynamically generated?
 *  Thread Starter [MarkPGray](https://wordpress.org/support/users/markpgray/)
 * (@markpgray)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/returning-field-slug/#post-5325376)
 * Within the flexible content field I have a layout field (called Section) which
   has two sub fields; a text field (Section Header) and a WYSIWYG field (section
   Content). This Section field can be repeated any number of times when adding 
   content to the backend. I need to dynamically generate an id for the Section 
   Header field so the the in-page navigation works.
 *  Thread Starter [MarkPGray](https://wordpress.org/support/users/markpgray/)
 * (@markpgray)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/returning-field-slug/#post-5325378)
 * Here’s the code I am using…
 *     ```
       [flex field="page_layout"]
       [layout name="section"]
       <h1 id="[section_header_field_slug_needed_here]">[sub field="section_header"]</h1>
       [sub field="section_content"]
       [/layout]
       [/flex]
       ```
   
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/returning-field-slug/#post-5325471)
 * With the latest update, you can generate unique IDs like this:
 *     ```
       <h1 id="section_header_{COUNT}">
       ```
   
 * So, the each header will have IDs like `section_header_1`, `section_header_2`
   and so on. Not exactly what you were asking for (field slugs), but I think that
   will achieve what you need?
 *  Thread Starter [MarkPGray](https://wordpress.org/support/users/markpgray/)
 * (@markpgray)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/returning-field-slug/#post-5325474)
 * Thank you, yes your suggestion will work just fine. Once again your generous 
   help is very much appreciated.
 *  Thread Starter [MarkPGray](https://wordpress.org/support/users/markpgray/)
 * (@markpgray)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/returning-field-slug/#post-5325475)
 * Whoops forgot to mark this as resolved.
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/returning-field-slug/#post-5325476)
 * Great, I’m glad it worked. 🙂

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Returning field slug’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-content-shortcode_766976.svg)
 * [Custom Content Shortcode](https://wordpress.org/plugins/custom-content-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-content-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-content-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-content-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-content-shortcode/reviews/)

 * 10 replies
 * 3 participants
 * Last reply from: [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/returning-field-slug/#post-5325476)
 * Status: resolved