background preloader

Advanced custom fields

Facebook Twitter

ACF { Add-on: Gallery Field. The Gallery field creates a simple and intuitive interface for managing a collection of images.

ACF { Add-on: Gallery Field

The interface features 2 different views for clients to better manage the data: Grid: a tiled view of all images – easy to reorder and scan large quantitiesList: a table like view showing the image’s data – easy to find / edit titles, captions, etc Simple to use, simple to code Use the get_field function to retrieve a multi-dimentional array containing all the images. Each image array holds all the image data (src, cropped sizes, alt, caption, etc). Read the Gallery field documentation for code examples » Requirements ACF version 3.2.9 or above License multi-site: You may use your activation code on multiple websites. Installation Upon purchase of this Add-on you will receive a recipt from PayPal, a receipt from ACF and a user account allowing access to your online receipts.

Depending on the version of ACF installed, you will find 2 methods of installing the Add-on. Version 4 and above. ACF { Documentation: Creating a front end form. Overview This article will cover how to create a form on the front end of your website to edit or create a new post.

ACF { Documentation: Creating a front end form

The functions acf_form() and acf_form_head() allow you to create a form to edit a page / post. Both functions are required in a template for the editing and saving behaviors to work correctly. Functions acf_form_head() This function registers the scripts / styles needed for the form (please note the admin styles may interfere with your template styles) and processes the $_POST data when the form is submitted. acf_form() This function creates the HTML for the form. you can pass an array of options to customize your form. Usage Place the acf_form_head() function at the very top of your template file. it is important that this function is placed before any html is rendered.Place the acf_form() function where you want the form to appear. Notes Using the acf_form() function will also include admin css & js files which may conflict with your website. ACF { Documentation: Displaying field data in your theme.

Overview The Advanced Custom Field’s API makes it very easy to display field data in your theme.

ACF { Documentation: Displaying field data in your theme

There are many functions available and all are well documented on the resources page. The Basics Once you have created a field group and input some data, you can now load and display the data in your theme. All values are saved as native post_meta (when saved to a post) and although you can use the native WP function get_post_meta(), it is better practice to use the relevant ACF function such as get_field(). To retrieve a field value as a variable, use the get_field() function. To display a field, use the the_field() in a similar fashion. Here’s a basic usage example, and please be sure to view the code example page for more. <? Does ACF have a Shortcode? Yes, you can use it in the same way as the the_field() function. [acf field="{$field_name}"] You can also specify the $post_id to fetch the value from.

[acf field="{$field_name}" post_id="{$post_id}"]