Below, you’ll find a detailed guide on how to add the Popular Brand Icons – Simple Icons Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Popular Brand Icons – Simple Icons Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the Popular Brand Icons – Simple Icons Plugin and the shortcodes it provides:
"Popular Brand Icons – Simple Icons is a handy WordPress plugin that offers a vast library of brand logos. Enhance your site's visuals and brand recognition with this easy-to-use tool."
- [simple_icon]
Simple Icons [simple_icon] Shortcode
The Simple Icons shortcode allows users to display icons on their website. Users can customize the icon’s appearance by specifying the icon slug, color, size, and CSS class. The shortcode fetches the relevant icon from the Simple Icons library. It also allows caching of the icon and inclusion of a title tag inside the SVG. If no name is provided, the output is set to false. Shortcode: [simple_icon]
Shortcode: [simple_icon]
Parameters
Here is a list of all possible simple_icon shortcode parameters and attributes:
name
– the slug of the desired icon (for example, ‘facebook’)color
– sets the color of the icon (for example, ‘blue’, ‘#fff’)size
– defines the size of the icon (for example, ’24px’, ‘1.5rem’)class
– applies a custom CSS class to the iconcache
– determines if the icon should be cached or nottitle_tag
– decides if atag should be included within the SVG
Examples and Usage
Basic example – Display a simple icon with the name parameter
[simple_icon name='facebook' /]
Advanced examples
Display an icon with a specific color and size
[simple_icon name='twitter' color='blue' size='24px' /]
Display an icon with a custom CSS class
[simple_icon name='instagram' class='my-custom-class' /]
Display an icon without caching it
[simple_icon name='linkedin' cache=false /]
Display an icon without the title tag inside SVG
[simple_icon name='youtube' title_tag=false /]
In these examples, replace ‘facebook’, ‘twitter’, ‘instagram’, ‘linkedin’, and ‘youtube’ with the name of the icon you want to display. Also, you can replace ‘blue’ with any color you want, ’24px’ with any size you want, and ‘my-custom-class’ with any custom CSS class you want to apply to the icon.
PHP Function Code
In case you have difficulties debugging what causing issues with [simple_icon]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'simple_icon', 'simpleicons_shortcode_func' );
Shortcode PHP function:
function simpleicons_shortcode_func($atts) {
global $simple_icons_debug;
// reset debug
$simple_icons_debug = array();
$a = shortcode_atts( array(
'name' => null, // icon slug (ie: facebook)
'color' => false, // (ie: blue, #fff, etc.)
'size' => null, // size of icon (ie: 24px, 1.5rem)
'class' => false, // custom CSS class name
'cache' => true, // cache the icon
'title_tag' => true // <title> tag inside svg
), $atts );
if (isset($a['name'])) {
$icon = new SimpleIcons();
$output = $icon->display_single_icon($a);
} else {
$output = false;
}
// loop through and output debug messages
if (SIMPLE_ICONS_DEBUG && $simple_icons_debug) {
foreach ($simple_icons_debug as $message) {
$output .= $message;
}
}
return $output;
}
Code file location:
simple-icons/simple-icons/simple-icons.php
Conclusion
Now that you’ve learned how to embed the Popular Brand Icons – Simple Icons Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply