Support » Plugin: Developer's Custom Fields » Retrieving key names and key/value pairs

  • Resolved timboreader


    Sorry if this is in the docs but I can’t find it.

    Is it possible to loop through all slt custom fields and retrieve their keys as well as their values?

    This function, I think, only retrieves the values of the fields: slt_cf_all_field_values()

    I would like to do two things:
    (1) Retrieve a list of the keys on their own (to output in a list)
    (2) Retrieve the keys at the same time as the values so I can assign them a css classname

    Even better would be able to retrieve the human readable ‘label’ as assigned when the fields are registered, which labels the fields at the back end. Can these be retrieved at the front end?

    Many thanks


Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Steve Taylor


    Hi Tim,

    I’ve never come across an instance where this might be necessary, but…

    There’s a function used internally: slt_cf_get_field_names( array('post'), array('text','textarea' ) ) – this instance would get the field names for all text and textarea fields assigned to posts. But it’s global – it doesn’t filter according to the current post.

    There’s also slt_cf_get_current_fields(), which will get the fields applied to the current object. It returns the full field definition array, including of course the name/key.

    Past that, you can access the global variable $slt_custom_fields to access all the registered information.

    Check the source – you should be able to get what you want with the above info!



    Hi Steve,
    Many thanks indeed for that info – I managed to achieve what I was aiming for, albeit not necessarily in the same elegant way I’d first envisaged!
    When the page is live I’ll write a blog post about what I did, as I do believe others may try to do achieve something similar.
    I’ve set the topic to ‘resolved’.
    Thanks again

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Retrieving key names and key/value pairs’ is closed to new replies.