### Run the Start Command
Source: https://www.advancedcustomfields.com/resources/compiling-multiple-acf-blocks-with-scripts
Execute the start command to set up a local development environment with hot module replacement (HMR) for real-time updates.
```bash
npm run start
```
--------------------------------
### Display Layouts Example
Source: https://www.advancedcustomfields.com/resources/functions/have_rows
Example of looping through a Flexible Content field to generate HTML for different layouts.
```php
```
--------------------------------
### Example composer.json for ACF
Source: https://www.advancedcustomfields.com/resources/installing-acf-with-composer
A complete example of a composer.json file including the ACF repository and requirement.
```json
{
"name": "wpengine/composer-test.dev",
"description": "ACF in a WordPress site",
"repositories": [
{
"type":"composer",
"url":"https://composer.advancedcustomfields.com"
}
],
"require": {
"wpengine/advanced-custom-fields": "^6"
}
}
```
--------------------------------
### Add Build and Start Scripts to package.json
Source: https://www.advancedcustomfields.com/resources/compiling-multiple-acf-blocks-with-scripts
Add the 'build' and 'start' commands to the scripts section of your package.json file to manage your block compilation workflow.
```json
{
"scripts": {
"build": "wp-scripts build",
"start": "wp-scripts start"
}
}
```
--------------------------------
### Full mu-plugin Example with Schema.org Enabled
Source: https://www.advancedcustomfields.com/resources/acf-machine-readable-content
This is an example of a complete mu-plugin file that enables both ACF AI and Schema.org support, along with configuring the Google Maps API key.
```php
```
--------------------------------
### Iterate and Output Field Values from a Field Group
Source: https://www.advancedcustomfields.com/resources/acf_get_fields
This example shows how to get all fields from a group, then loop through them to retrieve and display their values. It filters out empty values before storing them.
```php
$specifications_group_id = 'group_6525b4469c71d'; // Replace with your group ID
$specifications_fields = array();
$fields = acf_get_fields( $specifications_group_id );
foreach ( $fields as $field ) {
$field_value = get_field( $field['name'] );
if ( ! empty( $field_value ) ) {
$specifications_fields[ $field['name'] ] = $field_value;
}
}
```
--------------------------------
### Example: List Field Groups for AI Access
Source: https://www.advancedcustomfields.com/resources/ability-acf-field-groups
Use this example to list all field groups that have AI access enabled. Only groups with `allow_ai_access` set to `true` are returned.
```json
{
"field_groups": [
{
"ID": 45,
"key": "group_product_details",
"title": "Product Details",
"fields": [
{
"key": "field_price",
"label": "Price",
"name": "price",
"type": "number"
},
{
"key": "field_sku",
"label": "SKU",
"name": "sku",
"type": "text"
}
],
"location": [
[
{
"param": "post_type",
"operator": "==",
"value": "product"
}
]
],
"active": true,
"allow_ai_access": true,
"ai_description": "Core product information fields"
}
],
"count": 1,
"message": "Found 1 field group(s) with AI access enabled."
}
```
--------------------------------
### Install @wordpress/scripts
Source: https://www.advancedcustomfields.com/resources/compiling-multiple-acf-blocks-with-scripts
Install the @wordpress/scripts package as a development dependency in your project.
```bash
npm install @wordpress/scripts --save-dev
```
--------------------------------
### Example ACF Block Registration in block.json
Source: https://www.advancedcustomfields.com/resources/acf-block-configuration-via-block-json
This is a comprehensive example of a `block.json` file for an ACF Block, including core WordPress properties and ACF-specific configurations like `mode`.
```json
{
"name": "acf/testimonial",
"title": "Testimonial",
"description": "A custom testimonial block that uses ACF fields.",
"style": [ "file:./testimonial.css" ],
"category": "formatting",
"icon": "admin-comments",
"keywords": ["testimonial", "quote"],
"acf": {
"mode": "preview"
}
}
```
--------------------------------
### Nested Loops Example
Source: https://www.advancedcustomfields.com/resources/functions/have_rows
Example demonstrating how to loop through a nested Repeater field.
```php
```
--------------------------------
### Install ACF PRO as MU Plugin
Source: https://www.advancedcustomfields.com/resources/installing-acf-pro-with-composer
Modify 'installer-paths' to install ACF PRO into the wp-content/mu-plugins/ directory for must-use plugin functionality.
```json
"extra": {
"installer-paths": {
"wp-content/mu-plugins/{$name}/": ["wpengine/advanced-custom-fields-pro"]
}
}
```
--------------------------------
### Example: List all custom taxonomies registered through ACF
Source: https://www.advancedcustomfields.com/resources/ability-acf-custom-taxonomies
This example demonstrates how to retrieve all custom taxonomies that have been registered using ACF. It includes taxonomies with AI access enabled.
```json
{
"custom_taxonomies": [
{
"taxonomy": "event_category",
"label": "Event Category",
"plural_label": "Event Categories",
"hierarchical": true,
"public": true,
"post_types": ["event"],
"show_in_rest": true,
"allow_ai_access": true,
"ai_description": "Categories for classifying events by type"
},
{
"taxonomy": "event_tag",
"label": "Event Tag",
"plural_label": "Event Tags",
"hierarchical": false,
"public": true,
"post_types": ["event"],
"show_in_rest": true,
"allow_ai_access": true
}
],
"count": 2,
"message": "Found 2 ACF custom taxonomy(s)."
}
```
--------------------------------
### Example: Hooking into ACF Options Page Save
Source: https://www.advancedcustomfields.com/resources/acf-options_page-save
This example demonstrates how to hook into the 'acf/options_page/save' action to perform custom logic when a specific options page ('theme-settings') is saved. It shows how to retrieve saved fields and check specific field values.
```php
add_action('acf/options_page/save', 'my_acf_save_options_page', 10, 2);
function my_acf_save_options_page( $post_id, $menu_slug ) {
if ( 'theme-settings' !== $menu_slug ) {
return;
}
// Get newly saved values for the theme settings page.
$values = get_fields( $post_id );
// Check the new value of a specific field.
$analytics_code = get_field('analytics_code', $post_id);
if( $analytics_code ) {
// Do something...
}
}
```
--------------------------------
### Block Description Example
Source: https://www.advancedcustomfields.com/resources/acf_register_block_type
An optional short description for your block, providing more context to users.
```php
'description' => __('My testimonial block.'),
```
--------------------------------
### Example of Shortcode in Content
Source: https://www.advancedcustomfields.com/resources/shortcode
Demonstrates how to embed ACF shortcodes directly within text content to dynamically insert field values.
```html
This is a story about a boy named [acf field="name"]. He is [acf field="age"] years old.
```
--------------------------------
### Check if value exists
Source: https://www.advancedcustomfields.com/resources/functions/the_field
This example shows how to check if a value exists before displaying it.
```APIDOC
## Check if value exists
This example shows how to check if a value exists before displaying it.
```php
```
```
--------------------------------
### PHP Notice Example
Source: https://www.advancedcustomfields.com/resources/acf_add_options_page
This example demonstrates a PHP notice that can occur if ACF functions are called too early in the WordPress loading process. Ensure ACF functions are called after the 'acf/init' action.
```php
Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the acf domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later.
```
--------------------------------
### Block Keywords Example
Source: https://www.advancedcustomfields.com/resources/acf_register_block_type
An array of search terms to help users discover the block when searching in the Gutenberg editor.
```php
'keywords' => array('quote', 'mention', 'cite'),
```
--------------------------------
### Example Recipe Block JSON-LD Output
Source: https://www.advancedcustomfields.com/resources/structured-data-for-acf-blocks
This JSON-LD output is generated for a Recipe block, demonstrating the mapping of various fields to Schema.org properties.
```json
{
"@context": "https://schema.org",
"@type": "Recipe",
"name": "Chocolate Chip Cookies",
"description": "Classic homemade cookies",
"prepTime": "PT15M",
"cookTime": "PT12M",
"recipeYield": "24 cookies",
"recipeIngredient": [
"2 cups flour",
"1 cup sugar",
"1 cup chocolate chips"
],
"recipeInstructions": [
{
"@type": "HowToStep",
"text": "Preheat oven to 350°F"
},
{
"@type": "HowToStep",
"text": "Mix dry ingredients"
}
]
}
```
--------------------------------
### Testimonial Block CSS Styling
Source: https://www.advancedcustomfields.com/resources/acf_register_block_type
Example CSS for styling the testimonial block, setting background and text colors.
```css
.testimonial {
background: #00e4ba;
color: #fff;
}
```
--------------------------------
### Install ACF PRO via Composer CLI
Source: https://www.advancedcustomfields.com/resources/installing-acf-pro-with-composer
Use the Composer command-line interface to require the ACF PRO package for your project.
```bash
composer require wpengine/advanced-custom-fields-pro
```
--------------------------------
### Get a value from different objects
Source: https://www.advancedcustomfields.com/resources/functions/the_field
This example shows a variety of valid $post_id values that specify where the value is saved.
```APIDOC
## Get a value from different objects
This example shows a variety of valid **$post_id** values that specify where the value is saved.
```php
$post_id = false; // current post
$post_id = 123; // post ID = 123
$post_id = "user_123"; // user ID = 123
$post_id = "term_123"; // term ID = 123
$post_id = "category_123"; // same as above
$post_id = "option"; // options page
$post_id = "options"; // same as above
the_field( 'my_field', $post_id );
```
```
--------------------------------
### Block Name Example
Source: https://www.advancedcustomfields.com/resources/acf_register_block_type
A unique name is required for each block, consisting of lowercase alphanumeric characters and dashes, starting with a letter.
```php
'name' => 'testimonial',
```
--------------------------------
### Configure Block Preview Example
Source: https://www.advancedcustomfields.com/resources/acf_register_block_type
Provide an array of structured data for a preview shown in the block inserter. Data is accessible via `$block['data']` or `get_field()`.
```php
'example' => array(
'attributes' => array(
'mode' => 'preview',
'data' => array(
'testimonial' => "Your testimonial text here",
'author' => "John Smith"
)
)
)
```
--------------------------------
### Get a value from the current post
Source: https://www.advancedcustomfields.com/resources/get_field
This example demonstrates how to retrieve the value of a field named 'text_field' from the currently active post.
```PHP
```
--------------------------------
### Run the Build Command
Source: https://www.advancedcustomfields.com/resources/compiling-multiple-acf-blocks-with-scripts
Execute the build command to generate production-ready assets for your project. This creates compressed and optimized files in the 'build' directory.
```bash
npm run build
```
--------------------------------
### Get a value from a specific post
Source: https://www.advancedcustomfields.com/resources/functions/get_field
This example shows how to retrieve the value of a field named 'text_field' from a specific post identified by its ID (e.g., 123).
```APIDOC
## Get a value from a specific post
### Description
This example shows how to load the value of field ‘text_field’ from the post with ID = 123.
### Code
```php
$value = get_field( "text_field", 123 );
```
```
--------------------------------
### Get a value without formatting
Source: https://www.advancedcustomfields.com/resources/get_field
This example shows how to retrieve the raw database value of an image field by setting `$format_value` to false, bypassing any default formatting.
```PHP
```
--------------------------------
### Get a value from different objects
Source: https://www.advancedcustomfields.com/resources/functions/get_field
This example illustrates how to retrieve field values from various object types including posts, users, terms, and options by specifying different formats for the $post_id parameter.
```APIDOC
## Get a value from different objects
### Description
This example shows a variety of **$post_id** values to get a value from a post, user, term and option.
### Code
```php
$post_id = false; // current post
$post_id = 1; // post ID = 1
$post_id = "user_2"; // user ID = 2
$post_id = "category_3"; // category term ID = 3
$post_id = "event_4"; // event (custom taxonomy) term ID = 4
$post_id = "option"; // options page
$post_id = "options"; // same as above
$value = get_field( 'my_field', $post_id );
```
```
--------------------------------
### Get Fields for a Specific Field Group
Source: https://www.advancedcustomfields.com/resources/acf_get_fields
Use this to retrieve an array of all fields belonging to a specified field group. Ensure you replace the example group key with your actual field group key.
```php
acf_get_fields('group_6525b4469c71d');
```
--------------------------------
### Rapid Prototyping Prompt
Source: https://www.advancedcustomfields.com/resources/abilities-api
This prompt is used to automatically generate demo sites with realistic content structures for rapid prototyping.
```plain text
Set up a real estate site with property listings, agents, and neighborhood taxonomies.
```
--------------------------------
### Get a value without formatting
Source: https://www.advancedcustomfields.com/resources/functions/get_field
This example shows how to retrieve the raw database value of a field, bypassing any formatting logic, by setting the $format_value parameter to false. This is useful for fields like images where you might want the raw data.
```APIDOC
## Get a value without formatting
### Description
In this example, the field “image” is an image field which would normally return an Image object. However, by passing false as a 3rd parameter to the get_field function, the value is never formatted and returned as is from the Database. Please note the second parameter is set to **false** to target the current post.
### Code
```php
$image = get_field('image', false, false);
```
```
--------------------------------
### Example JSON-LD Recipe Output
Source: https://www.advancedcustomfields.com/resources/automatic-structured-data-with-schema-org
This JSON-LD snippet demonstrates how recipe information can be structured for search engines. It is typically placed in the `` section of a web page.
```json
{
"@context": "https://schema.org",
"@type": "Recipe",
"name": "Chocolate Chip Cookies",
"description": "Classic homemade chocolate chip cookies",
"prepTime": "PT15M",
"cookTime": "PT12M",
"recipeYield": "24 cookies",
"recipeIngredient": [
"2 cups flour",
"1 cup sugar",
"1 cup chocolate chips"
]
}
```
--------------------------------
### Display File Basic (URL Return)
Source: https://www.advancedcustomfields.com/resources/file
Directly displays a download link using the file's URL when the 'File URL' return type is selected.
```php
Download File
```
--------------------------------
### Display List of Post Objects with setup_postdata
Source: https://www.advancedcustomfields.com/resources/post-object
Loop through multiple Post Object values and display them as clickable links. This method uses `setup_postdata()` to enable standard WordPress template functions within the loop. The field's Return Format should be 'Post Object' and configured for multiple values.
```php
A custom field from this post:
```
--------------------------------
### Customize ACF Install Location
Source: https://www.advancedcustomfields.com/resources/installing-acf-with-composer
Add this to your composer.json to change the default installation path of the ACF plugin.
```json
"extra": {
"installer-paths": {
"wp-content/plugins/{$name}/": ["type:wordpress-plugin"]
}
}
```
--------------------------------
### Example Usage Note
Source: https://www.advancedcustomfields.com/resources/ability-acf-custom-post-types
This note clarifies that only post types registered through ACF are returned by the listing function. It also highlights that post types must have `show_in_rest` enabled for full accessibility via abilities.
```text
* Only post types registered through ACF are returned (not core or plugin post types)
* Post types must have `show_in_rest` enabled to be fully accessible via abilities
* Per-post-type abilities (query, create, view, update, delete) are registered dynamically for each post type with AI access
```
--------------------------------
### Add 'prepare' Action
Source: https://www.advancedcustomfields.com/resources/javascript-api
Use the 'prepare' action to perform customisation as early as possible in the footer, before the $(document).ready event.
```javascript
acf.addAction('prepare', function(){
$('#my-element').hide();
});
```
--------------------------------
### Check if a field value exists
Source: https://www.advancedcustomfields.com/resources/functions/get_field
This example demonstrates how to check if a field has a value before attempting to output it, using 'text_field' as an example.
```APIDOC
## Check if value exists
### Description
This example shows how to check if a value exists for a field.
### Code
```php
$value = get_field( "text_field" );
if( $value ) {
echo wp_kses_post( $value );
} else {
echo 'empty';
}
```
```
--------------------------------
### Create a Basic ACF Model
Source: https://www.advancedcustomfields.com/resources/javascript-api
Demonstrates creating a reusable model instance with custom methods, data attributes, event listeners, and initialization logic.
```javascript
var sidebar = new acf.Model({
wait: 'ready',
data: {
color: '#ffffff'
},
events: {
'click .select-color': 'onClick'
},
initialize: function(){
this.$el = $('#sidebar');
}
onClick: function( e, $el ){
// get color from data attribute on '.select-color' element
this.set('color', $el.data('color'));
// render
this.render();
},
render: function(){
this.$el.css('background-color', this.get('color'));
}
});
// interact directly with the sidebar variable
var color = sidebar.get('color');
```
--------------------------------
### PHP Date Formatting Example
Source: https://www.advancedcustomfields.com/resources/date-picker
Demonstrates a PHP date formatting string and its typical output. This is used to illustrate potential issues when passing dates to JavaScript libraries.
```php
echo date( 'F j, Y @ g:i a' );
```
--------------------------------
### Install ACF as MU-Plugin
Source: https://www.advancedcustomfields.com/resources/installing-acf-with-composer
Modify your composer.json to install ACF in the mu-plugins directory. You will need to manually require ACF in an acf.php file.
```json
"extra": {
"installer-paths": {
"wp-content/mu-plugins/{$name}/": ["wpengine/advanced-custom-fields"]
}
}
```
```php
Abraham Jebediah “Abe” Simpson II, commonly known as Grampa Simpson or simply Grampa, (born August 26, 1920) is a major character in The Simpsons. He is the oldest patriarch of the Simpson family, father of Homer Simpson, and paternal grandfather of Bart, Lisa and Maggie Simpson.\n",
"author_image": {
"ID": 3949,
"id": 3949,
"title": "Abraham_Simpson",
"filename": "Abraham_Simpson.webp",
"filesize": 28342,
"url": "https://hellfish.media/wp-content/uploads/2021/11/Abraham_Simpson.webp",
"link": "https://hellfish.media/book/tales-of-the-flying-hellfish/abraham_simpson/",
"alt": "",
"author": "1",
"description": "",
"caption": "",
"name": "abraham_simpson",
"status": "inherit",
"uploaded_to": 3944,
"date": "2021-11-15 10:11:31",
"modified": "2021-11-15 10:11:31",
"menu_order": 0,
"mime_type": "image/webp",
"type": "image",
"subtype": "webp",
"icon": "https://hellfish.media/wp-includes/images/media/default.png",
"width": 302,
"height": 482,
"sizes": {
"thumbnail": "https://hellfish.media/wp-content/uploads/2021/11/Abraham_Simpson-150x150.webp",
"thumbnail-width": 150,
"thumbnail-height": 150,
"medium": "https://hellfish.media/wp-content/uploads/2021/11/Abraham_Simpson-188x300.webp",
"medium-width": 188,
"medium-height": 300,
"medium_large": "https://hellfish.media/wp-content/uploads/2021/11/Abraham_Simpson.webp",
"medium_large-width": 302,
"medium_large-height": 482,
"large": "https://hellfish.media/wp-content/uploads/2021/11/Abraham_Simpson.webp",
"large-width": 302,
"large-height": 482,
"1536x1536": "https://hellfish.media/wp-content/uploads/2021/11/Abraham_Simpson.webp",
"1536x1536-width": 302,
"1536x1536-height": 482,
"2048x2048": "https://hellfish.media/wp-content/uploads/2021/11/Abraham_Simpson.webp",
"2048x2048-width": 302,
"2048x2048-height": 482,
"avatar": "https://hellfish.media/wp-content/uploads/2021/11/Abraham_Simpson.webp",
"avatar-width": 302,
"avatar-height": 482
}
}
}
}
```
--------------------------------
### Add Customized Options Page and Sub-Pages
Source: https://www.advancedcustomfields.com/resources/options-page
Demonstrates creating a main options page with custom settings and adding sub-pages for header and footer. All ACF functions are correctly hooked into the 'acf/init' action to prevent early initialization notices.
```php
add_action('acf/init', function() {
if( function_exists('acf_add_options_page') ) {
acf_add_options_page(array(
'page_title' => 'Theme General Settings',
'menu_title' => 'Theme Settings',
'menu_slug' => 'theme-general-settings',
'capability' => 'edit_posts',
'redirect' => false
));
acf_add_options_sub_page(array(
'page_title' => 'Theme Header Settings',
'menu_title' => 'Header',
'parent_slug' => 'theme-general-settings',
));
acf_add_options_sub_page(array(
'page_title' => 'Theme Footer Settings',
'menu_title' => 'Footer',
'parent_slug' => 'theme-general-settings',
));
}
});
```
--------------------------------
### Example REST API Response with Embed Link
Source: https://www.advancedcustomfields.com/resources/rest-api
Shows an example of how a User field might appear in a REST API response, including an embed link.
```json
"acf:user": [
{
"embeddable": true,
"href": "https://hellfish.media/wp-json/wp/v2/users/1"
}
],
```
--------------------------------
### Ready Action
Source: https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields
The 'ready' action is called when the document is ready and the page has initially loaded. It is equivalent to hooking into `$(document).ready()`.
```APIDOC
## Action: ready
### Description
Called when the document is ready once the page has initially loaded.
### Function Signature
`acf.add_action('ready', function( $el ) { ... });`
### Parameters
* `$el` (jQuery object) - Equivalent to `$('body')`.
### Example
```javascript
acf.add_action('ready', function( $el ) {
// Code to execute when the document is ready
var $field = $('#my-wrapper-id');
// Do something with $field
});
```
### Related Actions
This action also fires on each field via the actions `ready_field` and `ready_field/type={$field_type}`.
```
--------------------------------
### Enable Automatic Pre-Release Updates (Release Candidate)
Source: https://www.advancedcustomfields.com/resources/testing-pre-release-versions
Add this constant to your wp-config.php file to receive Release Candidate updates. These versions are more stable and closer to the final release.
```php
define( 'ACF_UPDATE_CHANNEL', 'RC' );
```
--------------------------------
### Modify Field Value Example
Source: https://www.advancedcustomfields.com/resources/acf-format_value
Example of a custom function to modify field values, demonstrating how to apply it to all fields or specific field types, names, or keys.
```php
```
--------------------------------
### Display Customized Image Size using Image Array
Source: https://www.advancedcustomfields.com/resources/image
This example shows how to display a specific image size (e.g., 'thumbnail') when the 'Return Format' is 'Image Array'. It accesses dimensions and other size-specific data.
```php
```
--------------------------------
### Display File Basic (Array Return)
Source: https://www.advancedcustomfields.com/resources/file
Displays a link to the file using its URL and filename when the 'File Array' return type is selected.
```php
```
--------------------------------
### Context-Aware Priority Schema.org Types
Source: https://www.advancedcustomfields.com/resources/acf-schema-schema_priority_types
This example customizes priority types based on the field group's title, providing context-aware suggestions. It checks for keywords like 'recipe' or 'product' to prepend relevant types.
```php
/**
* Context-aware priority types.
*
* @param array $priority_types Array of priority type names.
* @param int $context_id Field group ID or 0.
* @return array Modified priority types.
*/
function my_acf_schema_contextual_types( $priority_types, $context_id ) {
if ( ! $context_id ) {
return $priority_types;
}
$field_group = acf_get_field_group( $context_id );
if ( ! $field_group ) {
return $priority_types;
}
// Check field group title for context clues
$title = strtolower( $field_group['title'] );
if ( strpos( $title, 'recipe' ) !== false ) {
array_unshift( $priority_types, 'Recipe', 'HowTo' );
} elseif ( strpos( $title, 'product' ) !== false ) {
array_unshift( $priority_types, 'Product', 'Offer' );
}
return array_unique( $priority_types );
}
add_filter( 'acf/schema/schema_priority_types', 'my_acf_schema_contextual_types', 10, 2 );
```
--------------------------------
### GET Request for ACF Data
Source: https://www.advancedcustomfields.com/resources/rest-api
Use GET requests to retrieve ACF data for a specific post. The custom field data is returned within the 'acf' object in the response.
```APIDOC
## GET Request
### Description
A GET request will show the ACF data in the REST response.
### Method
GET
### Endpoint
`https://hellfish.media/wp-json/wp/v2/book/{ID}`
### Parameters
#### Path Parameters
- **ID** (integer) - Required - The ID of the book to retrieve ACF data for.
### Response
#### Success Response (200)
- **id** (integer) - The ID of the post.
- **date** (string) - The date the post was published.
- **date_gmt** (string) - The GMT date the post was published.
- **guid** (object) - Contains the GUID for the post.
- **modified** (string) - The date the post was last modified.
- **modified_gmt** (string) - The GMT date the post was last modified.
- **slug** (string) - The slug of the post.
- **status** (string) - The status of the post.
- **type** (string) - The post type.
- **link** (string) - The permalink to the post.
- **title** (object) - Contains the rendered title of the post.
- **content** (object) - Contains the rendered content of the post.
- **template** (string) - The template used for the post.
- **acf** (object) - Contains the custom field data for the post.
- **author** (string) - The author of the book.
### Response Example
```json
{
"id": 3944,
"date": "2021-11-15T10:11:38",
"date_gmt": "2021-11-15T10:11:38",
"guid": {
"rendered": "https://hellfish.media/?post_type=book&p=3944"
},
"modified": "2021-11-15T10:11:52",
"modified_gmt": "2021-11-15T10:11:52",
"slug": "tales-of-the-flying-hellfish",
"status": "publish",
"type": "book",
"link": "https://hellfish.media/book/tales-of-the-flying-hellfish/",
"title": {
"rendered": "Tales of the Flying Hellfish"
},
"content": {
"rendered": "
Presumably, the Flying Hellfish was first dispatched to Normandy for the Invasion of Normandy.
\n
Burns was always the unit’s troublemaker. The Hellfish got stuck with Burns because he obstructed a probe from J. Edgar Hoover, thus resulting in his demotion. He faked his own death several times and even ruined Simpson’s chance to assassinate Adolf Hitler.
\n
At one point, near the end of the war, the unit stormed a German castle. While searching through it, Private Burns found a collection of stolen paintings. While discussing what they should do with them, Burns mentions the idea of tontine, where the members must enter into a contract of when the last surviving member inherits the paintings if the others pass away. The unit agrees for their own personal reasons (Gumble wanting to buy his way into high society, Abe not wanting to end up “in one of them old folk’s homes”). Everyone signs and shakes on this prospect.
\n
Ox was the first member to die because of a hernia he got while taking the crate out of the castle. Five more were killed in a parade float accident in 1979. After Asa Phelps died, only Burns and Abe remained. Later, Simpson gave Burns a dishonorable discharge from the Hellfish for trying to kill him and his grandson Bart, expelling him from the tontine and declaring himself the sole possessor of the paintings in default, much to Burns’ dismay. Unfortunately for Grampa and Bart, their victory was cut short when the U.S. State Department arrive and took the paintings, as they have been searching for them for 50 years to avoid any international incidents with the German government. The State Department then returns the paintings to their rightful owner’s descendant, Baron von Herzenberger.
\n
\n",
"protected": false
},
"template": "",
"acf": {
"author": "Abraham Simpson"
}
}
```
```
--------------------------------
### Inline Style Example with Display Property
Source: https://www.advancedcustomfields.com/resources/html-escaping
Illustrates an inline style attribute containing the 'display: flex' property, which would typically be stripped by WordPress'skses functionality.
```html
```
--------------------------------
### Add 'ready' Action
Source: https://www.advancedcustomfields.com/resources/javascript-api
Use the 'ready' action to execute code during the $(document).ready() event.
```javascript
acf.addAction('ready', function(){
$('#my-element').hide();
});
```
--------------------------------
### View ACF Data with GET Request
Source: https://www.advancedcustomfields.com/resources/rest-api
Use a GET request to retrieve ACF data for a specific post. The custom field data will be available in the 'acf' JSON object within the response.
```json
{
"id": 3944,
"date": "2021-11-15T10:11:38",
"date_gmt": "2021-11-15T10:11:38",
"guid": {
"rendered": "https://hellfish.media/?post_type=book&p=3944"
},
"modified": "2021-11-15T10:11:52",
"modified_gmt": "2021-11-15T10:11:52",
"slug": "tales-of-the-flying-hellfish",
"status": "publish",
"type": "book",
"link": "https://hellfish.media/book/tales-of-the-flying-hellfish/",
"title": {
"rendered": "Tales of the Flying Hellfish"
},
"content": {
"rendered": "
Presumably, the Flying Hellfish was first dispatched to Normandy for the Invasion of Normandy.
\n
Burns was always the unit’s troublemaker. The Hellfish got stuck with Burns because he obstructed a probe from J. Edgar Hoover, thus resulting in his demotion. He faked his own death several times and even ruined Simpson’s chance to assassinate Adolf Hitler.
\n
At one point, near the end of the war, the unit stormed a German castle. While searching through it, Private Burns found a collection of stolen paintings. While discussing what they should do with them, Burns mentions the idea of tontine, where the members must enter into a contract of when the last surviving member inherits the paintings if the others pass away. The unit agrees for their own personal reasons (Gumble wanting to buy his way into high society, Abe not wanting to end up “in one of them old folk’s homes”). Everyone signs and shakes on this prospect.
\n
Ox was the first member to die because of a hernia he got while taking the crate out of the castle. Five more were killed in a parade float accident in 1979. After Asa Phelps died, only Burns and Abe remained. Later, Simpson gave Burns a dishonorable discharge from the Hellfish for trying to kill him and his grandson Bart, expelling him from the tontine and declaring himself the sole possessor of the paintings in default, much to Burns’ dismay. Unfortunately for Grampa and Bart, their victory was cut short when the U.S. State Department arrive and took the paintings, as they have been searching for them for 50 years to avoid any international incidents with the German government. The State Department then returns the paintings to their rightful owner’s descendant, Baron von Herzenberger.
\n
\n",
"protected": false
},
"template": "",
"acf": {
"author": "Abraham Simpson"
}
}
```
--------------------------------
### Hide ACF Admin Menu if Free Plugin Not Installed
Source: https://www.advancedcustomfields.com/resources/how-to-include-acf-in-a-plugin-or-theme
Hides the ACF admin menu items if the free ACF plugin is not installed. This prevents users from managing ACF settings if they don't have the free version active.
```php
// Check if ACF free is installed
if ( ! file_exists( WP_PLUGIN_DIR . '/advanced-custom-fields/acf.php' ) ) {
// Free plugin not installed
// Hide the ACF admin menu item.
add_filter( 'acf/settings/show_admin', '__return_false' );
// Hide the ACF Updates menu
add_filter( 'acf/settings/show_updates', '__return_false', 100 );
}
```
--------------------------------
### Create .gitignore File
Source: https://www.advancedcustomfields.com/resources/installing-acf-pro-with-composer
Create a .gitignore file in your project's root directory to prevent sensitive files like auth.json from being committed to version control.
```bash
touch .gitignore
```
--------------------------------
### Create Custom Taxonomy Input Example
Source: https://www.advancedcustomfields.com/resources/ability-acf-create-custom-taxonomy
This JSON object demonstrates the required input structure for creating a new custom taxonomy. It specifies the taxonomy key, singular and plural labels, and associated post types.
```json
{
"taxonomy": "product_category",
"label": "Product Category",
"plural_label": "Product Categories",
"post_types": ["product"]
}
```