Announcement

Collapse
No announcement yet.

HOW TO: Basic sample for a custom template with ACF fields

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • HOW TO: Basic sample for a custom template with ACF fields

    This is a follow up for this thread: http://cobaltapps.club/forum/ma...oman-in-a-shoe

    Is there a way to create a child page template with say 5 widget areas and each widget area will have different content depending on the child page? Once this template is created I would like to choose it when creating each child's page and then the associated widgets for the page show up in the appearance/widget area in wordpress dashboard and I can set up the content. I dont' want to have to set up 12 x 5 = 60 widget areas with conditionals (depending on page) in the Dynamik Custom Widget area.
    Now it wouldn´t really be convinient to handle that many widget areas and if you work for clients, it would also really be confusing for them. Plus: To access the widgets, they need higher user roles than for just editing any content and they can´t use the WYSIWYG editor there. And I assumed it is not really about that much widgets but rather about adding different content in widget-like columns.

    So I zipped up a basic sample from a playground I got, including a custom sample template and a field import for the free plugin "Advanced Custom Fields" (no live demo, screenshots added).

    You can explore how to:
    - Create a custom template for pages
    - Add the custom fields to it
    - Use the Genesis column classes to organize the content into columns
    - Use custom fields to pull in different content for different pages
    (you can change the settings for the fields)

    Note: This is just a very basic example (intended) and also it is not the only way to do this but just one possible way (hopefully a rather easy one) out of several (labels, conditionals, hooks, functions...).
    And if it´s really about needing widget areas to drag different widgets in, you might want to test these and see if they meet your criterias:
    https://wordpress.org/plugins/widget-shortcode/ (easiest to use as, after saving a widget, it displays the shortcode in the widget right away)
    https://wordpress.org/plugins/widget...per-shortcode/
    https://wordpress.org/plugins/amr-shortcode-any-widget/
    Once installed, they provide a shortcode for widgets to use in content areas.

    Instructions are in the download. Have fun!
    Download the files

    (Explanation: The two columns at the top and the three columns at the bottom of the page are displaying the fields - the content can be different for each and every page)

    EDIT: As a follow-up, I´d like to recommend the screencasts progedge has made, for example: http://cobaltapps.club/forum/ma...5955#post35955 (if you´re interested in how to use ACF, make sure you follow that thread!)
    Attached Files
    Last edited by SiGa; 04-28-2015, 03:55 PM.

  • #2
    Shameless curiosity strikes again!

    Comment


    • #3
      Hi Siga, thanks for the info on this - I'm really interested in this topic. But apart from the 3 x images & the link to the other thread, I can't find a 'download' ?
      TIA, Dave

      Comment


      • SiGa
        SiGa commented
        Editing a comment
        Do we? Must have missed it while I was asleep... LOL

      • sbhasker
        sbhasker commented
        Editing a comment
        You sleep SiGa? :-)

      • SiGa
        SiGa commented
        Editing a comment
        Now and then I do, imagine! It really helps. LOL

    • #4
      Great tutorial! Learned a lot! I have so much to learn, using genesis column classes and I didn't know about the Tools - Import - Wordpress feature to upload in import an xml file :-)

      Comment


      • SiGa
        SiGa commented
        Editing a comment
        Seems you´re on a good way.

    • #5
      With this, would it be possible to place actual widgets in the fields (e.g a featured page) or does this only work for text/images?

      Thank you!

      Comment


      • #6
        As stated above:
        And if it´s really about needing widget areas to drag different widgets in, you´d still have to create that amount of widget areas if there is no shortcode to use, sorry.
        Fields can hold text (including widget shortcodes or any other shortcodes for contact forms, sliders, galleries...), images, datepickers and more (see ACF description for info).
        ACF fields don´t display in Appearance - Widgets, so you can´t drag widgets in. I don´t know about other field plugins yet - you might want to search a bit, maybe there is one that has the feature?

        EDIT: Seeing this is possible (not tested): http://www.designly.net/blog/dynamic...custom-fields/
        .... I could well imagine there´s a solution to create widgetized areas if you´re familiar enough with PHP.
        Also there´s an addon I didn´t test yet: http://wordpress.org/plugins/advance...n/screenshots/
        Last edited by SiGa; 04-09-2014, 07:43 PM.

        Comment


        • #7
          To get this to be really easy to use for the editor, one could of course also use Visual Composer.
          It does add to a page rendering time for the visitor, and quite heavily to RAM usage for the server, though.

          Comment


          • SiGa
            SiGa commented
            Editing a comment
            But if I remember right: If you want different content for different pages/posts, you´d have to rebuild the layout in VC for each and every page/post - no?

          • Kellylise
            Kellylise commented
            Editing a comment
            FYI-Visual Composer has 2 template options: 1 to save/re-use VC layouts within the same WP installation, and an add-on plugin to share VC layouts with additional WP installations.

          • SiGa
            SiGa commented
            Editing a comment
            Well that´s good to know. Thanks for the additional info, Kelly.
        Working...
        X