Just Custom Fields for WordPress plugin

Alexander Prokopenko
Alexander Prokopenko Chief Technical Officer
4 minutes to read

Custom Post Types, announced in WordPress 3.0, boosted the popularity to WordPress sites among clients and developers in 2010. WordPress is quite easy for newbies in web to use, and it’s very simple and self-explanatory for content editors. With Custom Post Types we can improve standard functionality in times and add more sections (like Posts or Pages).

Another cool feature which gives you an option to improve your WordPress base is WordPress Custom Fields. However, for a non-technical person, it can be hard to use. We tried to use different plugins, which improve the usability of standard custom fields (like Custom Fields); however, we found a lot of major bugs there – it used a lot of memory etc. (it was far 2011 🙂 ). The now well-known plugin Advanced Custom Fields also wasn’t that good in 2011 with an unfriendly user interface and a very small amount of features.

We decided to create our own Custom Fields plugin, which wouldn’t use a lot of memory yet still be easy to use and easy to expand.

In July 2011 we announced our new plugin named “Just Custom Fields for WordPress“. This plugin adds custom fields for standard and custom post types in WordPress. After installation, you will see a simple settings page which is self-explanatory to use.

Installation:

  1. Download, unzip and upload to your WordPress plugins directory
  2. Activate the plugin within your WordPress Administration Backend
  3. Go to Settings > Just Custom Fields
  4. Choose Post Type (Standard/Custom) where you would like to edit custom fields
  5. Create Fieldset
  6. Add fields to the fieldset.

Screenshots:

On this screenshot, you can see the settings page for a “Page post type. You can create fieldsets and fields inside of it. This page uses WordPress AJAX API, so it updates without any redirects and editing, rather quickly.

jcf1_settings-1100x604 Just Custom Fields for WordPress plugin

You can create a field with one of the types below:

  • Input text: usual single-line text box
  • Select: usual dropdown list
  • Select Multiple: area which allows you to select multiple options from the list
  • Checkbox: you can add one or multiple checkboxes
  • Textarea: multi-line text field. You can also enable WordPress editor for this field
  • Datepicker: input field with calendar popup to choose a date
  • Simple media: use this field to create an image or file container
  • Collection: with the help of this field, you can create multiple groups of fields, which can be repeated a number of times. You can add other field to this collection. For example, you can create your own Gallery, by adding Simple media for image, Input Text for Title, and Textarea for description.
  • Related Content: using this field allows you to link other post types with your post

The following screenshot illustrates how a fieldset will look on a post edit page. There is the usual text box, select box, file upload and Collection with Simple media field (as you can see you can upload many images in this way).

jcf2_post_edit-1100x728 Just Custom Fields for WordPress plugin

WordPress developers also find this plugin very useful as it’s very easy to add their own components and custom fields with their own plugins and even themes, using some new hooks. For more details, you are welcome to check readme.txt file from the plugin package.

Templates usage

Using WordPress Shortcode functions

If you are not familiar with Post meta API we recommend using the plugin shortcodes, presented in version 2.2.

You can find usage instructions on the post edit page, under help popup. Just insert code example into your template, and it will print the value for you.

jcf3_help_popup-1100x470 Just Custom Fields for WordPress plugin

Shortcode adds a lot of HTML wrappers for frontend developers to be able to style/position value for any needs.

Working with Post Meta directly

For skilled WordPress developers, we recommend using native post meta functions such as:

Let’s show some examples. We created 3 custom fields for the Page with the following slugs:

  • _price (Input Text)
  • _features (Checkboxes/multiple)
  • _author_avatar (Simple Media / image)

To get values in templates, you need to place the following lines of code inside the loop functions:

$price = get_post_meta(get_the_ID(), '_price', true); // we get value from input text
$avatar_id = get_post_meta(get_the_ID(), '_author_avatar', true); // we get image attachment ID
$features = get_post_meta(get_the_ID(), '_features', true); // we get array of checked checkboxes

Now, when you have variables with the data, you can print them in the template. For example like this:


Price: <?php echo $price; ?>
Features: <?php foreach($features as $feature) echo $feature.','; ?>
Avatar: <?php wp_get_attachment_image($avatar_id, ‘thumbnail’); ?>

You can read more about using custom fields on Codex.WordPress.org: Custom Fields or search for more information in Google. There are a lot of examples on different sites demonstrating how to use WordPress custom fields. Our plugin creates an easy interface to edit in the administration panel, and you can use all built-in WordPress functions for custom fields.

Download

Our plugin is available for downloading in official WordPress repository:

Just Custom Fields for WordPress at WordPress.org repository

5/5 - (1 vote)

Book a call With our strategist

What we will talk about:
  • you and your business needs;
  • current plans, ideas, and strategy;
  • possible solution to your business challenge.

Describe your business requirements in enough details so we could understand your goal better.

*If an NDA should come first, please let us know.