AI Verified

Name

Custom Field SVG

About

This is how to add Custom Field SVGs to your Loop Grid.

Language

PHP

Rating

Voted: 0 by 0 user(s)

How to Setup Snippet

Add a File ACF Field. Then add the SVG per post. Then use the shortcode from the code.

Codevault

WebSquadron

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: 6.4

Our AI bot has checked this snippet is compatable up to wordpress version: 6.1

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

History

Last modified:

28/02/2024

Important Note

This snippet has the following status:

AI Verified

This snippet has been tested by our AI bot, see any comments below.

AI Bot Comments:

Found 0 vulnerabilities

Custom Field SVG

 
                    
1function display_acf_svg_shortcode() {
2 $svg_field = get_field('svg_icon');
3 if($svg_field) {
4 // If the field returns an array, get the URL from the array.
5 $svg_url = is_array($svg_field) ? $svg_field['url'] : $svg_field;
6 return '<img src="' . esc_url($svg_url) . '" alt="SVG Icon" />';
7 }
8 return '';
9}
10add_shortcode('display_acf_svg', 'display_acf_svg_shortcode');

0

Related Snippets

Please see some snippets below related to this snippet..

General

AI Verified

0

Gravity Forms: Exclude fields with visibility hidden from {all_fields} merge tag with :nohidden modifier

Added: 1 year ago

Last Updated: 1 year ago

This example extends the default nohidden modifier to also exclude fields with the visibility setting set to hidden.

General

AI Verified

4

Allow SVG

Added: 1 year ago

Last Updated: 2 weeks ago

Allow SVG upload without a plugin

General

AI Verified

0

Content Control - Debug Early Loaded Rules Source

Added: 9 months ago

Last Updated: 9 months ago

Allows debugging which plugin/theme/code is causing Content Control rules to be registered too early.

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

Performance

AI Verified

32

Remove Unused Javascript

Added: 1 year ago

Last Updated: 3 days ago

Remove Unused Javascript - and improve your Page Speed Insight Score

WooCommerce

Pro Verified

10

Deactivate some WooCommerce Checkout Fields

Added: 1 year ago

Last Updated: 2 weeks ago

Deactivate some WooCommerce Checkout Fields from showing

Elementor

AI Verified

6

CSS Grid Aid

Added: 8 months ago

Last Updated: 1 month ago

This can be used for any WordPress Builder to aid working with CSS Grids.