Displaying fields with a shortcode for CFS

I wrote a bit previously about the Custom Field Suite plugin here: https://ugotsta.wordpress.com/2015/07/18/displaying-all-fields-with-custom-field-suite/

To reiterate, Custom Field Suite is a powerful, free plugin for easily creating custom fields in WordPress using an elegant graphic interface.

One problem

As amazing as this plugin (and it’s elegant interface) is, non-developers will likely struggle to display their custom fields. It requires custom PHP code.

While the plugin makes it dead simple for developers to code their custom solution, it’s not quite so easy for non-developers. So I’ve been working to simplify that.

Here’s the result so far:

With that downloaded and installed as a plugin, you’ll have a simple shortcode at your disposal:

[cfs-fields]

That little shortcode will render all the fields for the currently viewed post in a list. It works with no parameters by default, but there are a bunch of options if needed:

  • exclude: a comma-delimited list of field names to exclude
  • exclude_titles: a comma-delimited list of field names for which to “not” render titles.
  • container_class: a CSS class for the container, if needed, to easily target items.
  • field_class: a CSS class for each field.
  • list_type: an option to render the fields as lists or divs; ordered, unordered or div.
  • render_post_title: true to render the title, false otherwise.
  • render_empty: true to render empty fields (fields with no value specified), false to not display them.

As an example, if you had a bunch of fields to display but wanted to hide the fields with the names, ‘id’ and ‘release_year’, you could use the shortcode like so:

[cfs-fields exclude=”id, release_year”]

Again, those options are not necessary. The shortcode will just fine on its own.

There’s a lot more I should say about it, but I hope this much info helps for those looking to easily display their fields with CFS. As I get this one more refined, I’ll get some more extensive info and a video to walk through it.

Any questions, just let me know. 🙂

Advertisements
Displaying fields with a shortcode for CFS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s