Advanced Custom Fields: Snippets

Advanced Custom Fields: Snippets

Wordpress plugin

Install on Wordpress

App Details

Adds useful functions for rendering image fields, link fields, repeater fields and flexible content for the Advanced Custom Fields plugin. For detailed info look on Bitbucket.

Main advantages

  • write less code (do not repet same blocks of the code when writing down ACF custom fields)
  • built-in filters
  • works also for Gutenberg ACF Blocks
  • no init hooks etc (no impact on performance)

Usage

Link

Returns the snippet of a specific link field.

<?php acf_snippet_get_link($selector, [$postId], [$args]); ?> 

Displays the snippet of a specific link field.

<?php acf_snippet_the_link($selector, [$postId], [$args]); ?> 

Parameters
$selector (string) (Required) ACF field name or ACF field key. Based on ACF get_field function.
$postId (integer|bool) (Optional) The post ID where the value is saved. Use true for getting sub field. Default value: false (current post).
$args (array) (Optional) Array of link output arguments. Default value: null.
&nbsp;&nbsp;&nbsp;&nbsp;‘class’ (string) class attribute of the anchor.
&nbsp;&nbsp;&nbsp;&nbsp;‘id’ (string) id attribute of the anchor.
&nbsp;&nbsp;&nbsp;&nbsp;‘title’ (string) title attribute text of the anchor.

Image

Returns the snippet of a specific image field.

<?php acf_snippet_get_image($selector, [$postId], [$args]); ?> 

Displays the snippet of a specific image field.

<?php acf_snippet_the_image($selector, [$postId], [$args]); ?> 

Parameters
$selector (string) (Required) ACF field name or ACF field key. Based on ACF get_field function.
$postId (integer|bool) (Optional) The post ID where the value is saved. Use true for getting sub field. Default value: false (current post).
$args (array) (Optional) Array of image output arguments. Default value: null.
&nbsp;&nbsp;&nbsp;&nbsp;‘size’ (string) Image size to use. Accepts any valid image size. Default value is full.
&nbsp;&nbsp;&nbsp;&nbsp;‘alt’ (string) alt attribute of the image.
&nbsp;&nbsp;&nbsp;&nbsp;‘id’ (string) id attribute of the image.
&nbsp;&nbsp;&nbsp;&nbsp;‘class’ (string) class attribute of the image.
&nbsp;&nbsp;&nbsp;&nbsp;‘title’ (string) title attribute of the image.
&nbsp;&nbsp;&nbsp;&nbsp;‘srcset’ (bool) Use true for retrieving image’s srcset attribute. Default value: false.
&nbsp;&nbsp;&nbsp;&nbsp;‘loading’ (string) loading attribute of the image. Default value: lazy.
&nbsp;&nbsp;&nbsp;&nbsp;‘link’ (bool|array) Array of attributes for anchor wrapped around the image. Default value: false.
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;‘href’ (string) href attribute of the link.
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;‘target’ (string) target attribute of the link.
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;‘class’ (string) class attribute of the link.
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;‘id’ (string) id attribute of the link.
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;‘title’ (string) title attribute of the link.

Repeater

Displays the snippet of a specific repeater field.

<?php acf_snippet_the_repeater($selector, [$postId], [$args]); ?> 

Parameters
$selector (string) (Required) ACF field name or ACF field key. Based on ACF get_field function.
$postId (integer|bool) (Optional) The post ID where the value is saved. Default value: false (current post).
$args (array) (Optional) Array of repeater output arguments. Default value: null.
&nbsp;&nbsp;&nbsp;&nbsp;‘template’ (string|array) Template for items inside the loop. Arguments of get_template_part function. In the template use standard get_sub_field function.
&nbsp;&nbsp;&nbsp;&nbsp;‘wrap_before’ (string) Text (HTML) before repeater items while have rows.
&nbsp;&nbsp;&nbsp;&nbsp;‘wrap_after’ (string) Text (HTML) after repeater items while have rows
&nbsp;&nbsp;&nbsp;&nbsp;’empty_html’ (string) Text (HTML) in case there are no rows in repeater.

Flexible content

Displays the snippet of a specific flexible field.

<?php acf_snippet_the_flexible_content($selector, [$postId], [$args]); ?> 

Parameters
$selector (string) (Required) ACF field name or ACF field key. Based on ACF get_field function.
$postId (integer|bool) (Optional) The post ID where the value is saved. Default value: false (current post).
$args (array) (Optional) Array of flexible content output arguments. Default value: null.
&nbsp;&nbsp;&nbsp;&nbsp;‘templates’ (array) Array of templates for flexible content layouts. In the templates use standard get_sub_field function.
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key (string) – layout name
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value (string|array) arguments for get_template_part function.

Requires Advanced Custom Fields (Pro)

Examples

Link field

<?php acf_snippet_the_link('more_info_link', false, [ 'class'=> 'link__out', ] ); ?> 

Image field

<?php echo acf_snippet_get_image('logo', 'option', [ 'size' => 'medium', 'alt' => 'company name', 'title' => false, 'class' => 'header__logo', 'id' => 'company-logo', 'loading' => 'fetch', 'link' => [ 'href' => get_home_url() ] ] ); ?> 

Repeater field

<?php acf_snippet_the_repeater( 'team_members', false, [ 'template' => [ 'templates/loops/loop', 'team-member' ], 'wrap_before' => '<ul class="about__team">', 'wrap_after' => '</ul>', 'empty_html' => '<p>' . __( 'No team members to show.', 'web' ) . '</p>' ] ); ?> 

Flexible content field

<?php acf_snippet_the_flexible_content( 'fp_content', false, [ 'templates' => [ 'slider' => [ 'templates/homepage/snippet', 'slider' ], 'counters' => [ 'templates/homepage/snippet', 'counters' ], 'text_block' => [ 'templates/homepage/snippet', 'text_block' ] ] ] ); 

?>
`

Pricing

Starting from $0 per month.

Check Out the Multi-Row Image Slider Widget

By Common Ninja

Multi-Row Image SliderTry For Free!

App Info

Rating

Reviewers

No reviews

Tags

acf
advanced custom fields
snippets

Developed By

tomekthewo

Quick & Easy

Find the Best Wordpress plugins for you

Common Ninja has a large selection of powerful Wordpress plugins that are easy to use, fully customizable, mobile-friendly and rich with features — so be sure to check them out!

Testimonial

Testimonial plugins for Wordpress

Contact Form

Contact Form plugins for Wordpress

Maps

Maps plugins for Wordpress

Translation

Translation plugins for Wordpress

Chat

Chat plugins for Wordpress

Slider

Slider plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Contact

Contact plugins for Wordpress

Galleries

Galleries plugins for Wordpress

SEO

SEO plugins for Wordpress

Forms

Forms plugins for Wordpress

Comments

Comments plugins for Wordpress

Backup

Backup plugins for Wordpress

Privacy

Privacy plugins for Wordpress

Optimize

Optimize plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Comments

Comments plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Video Player

Video Player plugins for Wordpress

popup

popup plugins for Wordpress

SiteMap

SiteMap plugins for Wordpress

Payment

Payment plugins for Wordpress

Coming Soon

Coming Soon plugins for Wordpress

Inventory

Inventory plugins for Wordpress

Testimonials

Testimonials plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Membership

Membership plugins for Wordpress

Forms

Forms plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Sliders

Sliders plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Security

Security plugins for Wordpress

Ads

Ads plugins for Wordpress

Music Player

Music Player plugins for Wordpress

Countdown

Countdown plugins for Wordpress

Email Marketing

Email Marketing plugins for Wordpress

Membership

Membership plugins for Wordpress

Ecommerce

Ecommerce plugins for Wordpress

Customer Support

Customer Support plugins for Wordpress

Video Player

Video Player plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Common Ninja Apps

Some of the best Common Ninja plugins for Wordpress

Browse our extensive collection of compatible plugins, and easily embed them on any website, blog, online store, e-commerce platform, or site builder.

Multi-Row Image Slider for Wordpress logo

Multi-Row Image Slider

Showcase visuals with a multi row image slider that displays images in layered rows, improves design, and helps visitors explore content more easily.

Scroll Progress for Wordpress logo

Scroll Progress

Use a scroll progress bar that visually tracks reading on the page, improves navigation, and keeps visitors aware of their position.

Payment Method Logos for Wordpress logo

Payment Method Logos

Show payment method logos that highlight accepted payment options, build trust at checkout, and help visitors feel confident completing their purchase.

Social Proof Avatars for Wordpress logo

Social Proof Avatars

Display social proof avatars that show user activity and ratings, build trust instantly, and help visitors feel confident about your credibility.

Vimeo Slider for Wordpress logo

Vimeo Slider

Show Vimeo videos with a Vimeo slider that displays clips in a smooth slider to boost engagement and keep visitors watching.

Music Player for Wordpress logo

Music Player

Add a no-code music player to your site to stream audio, share playlists, and support multiple formats with easy setup.

Capterra Reviews for Wordpress logo

Capterra Reviews

Show Capterra reviews to build trust, strengthen credibility, and help visitors make confident software buying decisions that support higher sales.

Social Votes for Wordpress logo

Social Votes

Encourage interaction with social votes that let visitors like, upvote, and rank content, boosting engagement and guiding better decisions.

Email Subscription Form for Wordpress logo

Email Subscription Form

Capture email leads with an email subscription form that collects addresses, saves entries, sends notifications, and helps grow your audience.

Card Carousel for Wordpress logo

Card Carousel

Showcase content with a card carousel that combines images and text, improves visual design, and helps visitors explore key information.

Logo Slider for Wordpress logo

Logo Slider

Add a logo slider to your site to showcase clients and partners, strengthen brand credibility, and build trust with new visitors.

Marketing Button for Wordpress logo

Marketing Button

Marketing button with text and an icon that highlights key offers, draws attention to promotions, and helps increase engagement and conversions.

More plugins

plugins You Might Like

Discover Apps By Platform

Discover the best apps for your website

WordPress
Wix
Shopify
Weebly
Webflow
Joomla
PrestaShop
Shift4Shop
WebsiteX5
MODX
Opencart
NopCommerce

Common Ninja Search Engine

The Common Ninja Search Engine platform helps website builders find the best site widgets, apps, plugins, tools, add-ons, and extensions! Compatible with all major website building platforms - big or small - and updated regularly, our Search Engine tool provides you with the business tools your site needs!

Multiple platforms