Simple Fields tutorial, part 1: adding fields

Note: this tutorial is pretty old. The new and cool and recommended way to add field groups and fields and post connector is to use php in your functions.php. Quick ref: this gist and this gist.


 

In this short tutorial I will show you how to create a Simple Fields-box on your page edit screen. It will that displays some options related to the article.

The end result will look like this:

Step 1: set up a field group

The first thing we do is go to Simple Fields admin and choose to create a new field group.

We give the field group a suiting name, like “Options” – this is the name that later will be shown on the page edit screen.

After that we just add all the fields that we want and you should end up with something like this:

Now click “Save Changes” and you’ll return to the main Simple Fields admin screen.

Step 2: setup a post connector

Next we need to create a post connector, so click “New post connector”.

Give the new post connector a name, preferable something that explains in what context it will be used. I’ll name it “Regular post”, because I want to use this connector for regular posts.

Now choose “Options” from the add-field-group-dropdown to add our previosuly added field group to this connector.

Lastly click check “page” under “Available for post types”. This makes this connector available for all our pages.

Now click “Save Changes” to return to the main screen again.

Step 3: setup post type default

Now let’s do one final thing in the Simple Fields admin: set a default connector for a post. Under “Post type defaults” click “Pages” and choose “Regular post” in the dropdown. Save and return to the main screen again.

…and we’re done

After returning to the main Simple Fields screen, it should look like this:

Let’s se our result

Now let’s go and create a new page. You should see a new box called “Options” that contains all the fields that we added previously.

28 thoughts on “Simple Fields tutorial, part 1: adding fields

  1. eskaigualker

    Is this correct? “Now let’s go and create a new page. You should see a new box called “Options” that contains all the fields that we added previously.”

    Or it is necessary to save before the new post??

          1. Parag BD

            I can see the fields in edit mood…but when I publish the page no fields are shown on that page… whats wrong with 3rd step..pls suggest.

  2. eitan haker

    hi love the plugin great one
    i have a small probelm

    i open a new text filed im trying to display next gen short code

    [nggallery id=3]

    it shows the shortcod e but no gallery

    when i move the shortcode to content iot works
    for some reason it doesnt except it

    im using advanced text area

    any clues how can i fix it

    thanks
    eitan

  3. mukund

    i have done all step is seen in post edit box bt how i should add it to that post/ page when i preview it do show nothing

    1. Flash Buddy

      I suppose the easiest thing for a developer to do is echo out the content on the front end. ERGO, they often fail to cover that aspect in their documentation. To be fair, I haven’t read the documentation for this plugin, yet…

      To display the content one needs to add code to ones WordPress theme. Generally that will be page.php for pages, single.php for posts and home or index.php for the home page.

      I keep a running list of code that I’ve used in the past, or seen used in ways that may come in handy one day.

      In the case of this plugin, the author provides an example (FAQ page of this site):

      <img src="” alt=”An image” />

      If one replaces fieldGroupID, the the one created, you will be able to show your referenced/uploaded image.

      I like the concept here. A forum, contributors area and example code page will be great tools going forward.

  4. Jack

    Well, maybe I missunderstood something, however datepicker doesn’t work with WP 3.3.2. It shows empty field wehere you have to write the date mannually. What could be wrong with it – other options work fine, thank you

  5. James

    ffs: third time lucky:

    get_post_meta($post->ID, “_simple_fields_fieldGroupID_1_fieldID_1_numInSet_0”, true);

  6. James

    whoops, it chopped it off:

    ID, “_simple_fields_fieldGroupID_1_fieldID_1_numInSet_0″, true);
    $img_src = wp_get_attachment_url($image_id, ‘thumbnail’);
    ?>
    <img src="” alt=”An image” />

  7. James

    THIS IS HOW YOU GET A FILE TO DISPLAY USING HTML AND PHP:

    In your posts you have a file field… upload an image and save your post.

    Put into your displaying html:

    ID, “_simple_fields_fieldGroupID_1_fieldID_1_numInSet_0″, true);
    $img_src = wp_get_attachment_url($image_id, ‘thumbnail’);
    ?>
    <img src="” alt=”An image” />

    this will display the first image.

    still working out how to find some sort of array which tells you how many fields are in one group

  8. Yasmin

    Hello, I have read and reread your tutorial and followed your instructions, however it is not completely working.

    It shows up on the post edit page in admin, but does not show up on the post in the frontend / on website.

    Why do you think it’s doing this?

    Otherwise it’s perfect!

      1. Pär Thernström Post author

        The fields does not show up automatically on the front end. Because there are many field types to choose from and so many different combinations of fields possible, you must edit your templates manually and add PHP code to get and show your fields.

  9. burntdownhouse

    Anyone noticed that even if you delete a simple field on an individual page it keeps coming back when you re-publish/save?

  10. Paul

    Hi Pär

    I was wondering if the post connector’s option can be extended to ‘page-template.php’? or it could only be for Post Type only ?

  11. Staffan Estberg

    Hej Pär!

    Trillade över din blogg och ditt fantastiska plug-in häromdagen och beslutade mig för att använda det till en site jag utvecklar just nu. Har dock hamnat lite i kläm – jag har skapat en Custom Post Type och siten använder sig av flera språk. Kör WPML men lyckas inte sätta rätt parents i CTPn, varför jag överväger att skippa det och använda ditt plug-in på en viss kategori i vanliga Posts. Går det att göra? Det hade varit grymt användbart om man kunde välja inte bara en sida/posttyp utan även en kategori som tillhör den. Vad tror du?

    1. Pär Post author

      Tjena och tack för berömmet 🙂

      Är inte säker på att jag helt hänger med på vad du menar. Kan du förklara igen, lite annorlunda kanske..?

      1. Staffan Estberg

        Absolut 😉

        WPML har inte direkt nåt att göra med ditt plug-in utan ville bara förklara anledningen till att jag valt att försöka gå en annan väg med custom post types, nämligen att skippa dem och bara använda mig av categories istället för att dela upp Posts i olika segment. Det jag undrar kort och gott är om det finns en möjlighet att välja en Connector som är just en kategori till Posts, och inte Posts generellt? T ex Posts category news. Och sen applicera en Field Group till den?

        1. Pär Post author

          Ah, ok, tror jag är med nu!

          Spontant så ser jag lite problem med att koppla post connector till kategorier. Det känns som att det lätt krockar om man har post connectors kopplade till flera kategorier (vilken är det som gäller då t.ex.) samt att det krockar med connectorn för posten. Allt går såklart att göra men jag känner så här direkt att det blir ett lite för stort projekt att sätta igång med. Sorry.. :/

Leave a Reply