I checked your code in my install. It works, except that you made a typo (missing backslash):
[icon]cog[/icon]
Few notes:
-
You must make sure to enqueue the Font Awsesome stylesheet.
-
You must close the shortcode, like:
[icon]cog[/icon]
-
Remember to escape the class name with
esc_attr()
. -
Another shortcode idea:
[fa icon="cog"]
Related Posts:
- WordPress menu deletes when trying to add a hook
- PHP contact form returns warning in text widget [closed]
- Add a specific part of current category page url to shortcode
- WordPress Shortcodes.. printf is outputting a random number… Can’t figure out WHY?
- How to Create custom block for displaying information in content section which act like shortcode
- Shortcodes not processing inside post content
- I want to hide “sold by” on certain pages with id page 43
- Reload page with a different shortcode when a user selects from a dropdown
- PHP Widget and do_shortcode
- How to edit a widget code?
- How to put a variable in a instance in the widget
- How to output widget
- Different loop output every x posts in custom post type
- add_action shortcut?
- How to output a PHP file values by shortcode?
- Showing content from one page on another
- Extending the WP_Widget_Text class
- Is it acceptable to treat a filter like an action?
- Showing a different gallery in a seperate post
- Dynamic Sidebars & Echo
- How to display posts by current user in a drop down
- Create own WordPress shortcode gallery
- How can I remove a function that has been added to wordpress with add_filter?
- How to control WordPress image metadata (using Imagick)?
- Get value from shortcode to do something
- Edit incorrect password message WordPress
- How do I add custom bulk actions to multiple custom post types?
- Add data attribute to each li in menu
- Show prices with tax in Woocommerce Mini Cart [closed]
- Ajax category filtering products default show all
- How to exclude category ID from Looper in WordPress
- How to display data from custom table in wordpress phpmyadmin
- Calculating a large number of MYSQL queries as customshort codes, slow
- Why does my callback function not work with this custom filter hook?
- Contact Fom 7 – how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control?
- Removing “wpautop” (auto tags) only on certain pages?
- Colon is Missing In My Website Url in WordPress
- Add filter when image is uploaded?
- Remove the first 5 characters of the_title and orderby that
- Remove a div from RSS feed
- Print last modified date only on posts
- How to add an arrow to menu items has submenus
- WordPress Gravatar filter is removing my custom attributes
- How to make my custom widget appear within WordPress widgets? Plugin development
- get widget number from array dynamically
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- Custom shortcode outputs plain text instead of HTML at top of post
- Adding widgets to my plugin page instead of WordPress dashboard
- How to use wp_add_inline_style for custom CSS added via shortcode?
- Pass php dynamic variable to shortcode
- How can I dynamically update the class in my shortcode?
- Creating own shortcode – echoeing php variable based on JS variable
- Unique icons next to each WordPress menu item
- Hide subcategories (widget)
- Why my image upload button is not working in wordpress widget area?
- How create a Shortcode with hover and complex options
- Remove from shortcode
- Adding a widget function into the php theme file
- Displaying recent posts on static page with template-part via shortcode
- How to edit widget code to add unique class name to each div?
- wordpress 4.4 self hosted video (html5) doesn’t show
- do_shortcode with custom field
- Change tinyMCE editor to allow marked content when pasting from Word
- How to Reference/Echo Variable from Another PHP Function
- Remove echo from shortcode
- Replace shortcode in substring
- Problem with login form
- If has $title in widgets
- Shortcode to show the code
- Archives shortcode displaying above widget title
- Shortcode returns values in the wrong order
- Redirect to another page using contact form 7? [closed]
- Widgets in the loop if active
- Get URL from shortcode tag
- Embedding PHP in shortcode $content
- Alter required message using comment form api
- How to debug this search & replace strings snippet?
- Show latest posts in a plain HTML website custom widget [closed]
- Shortcode with PHP issue “Undefined index”
- Hide Featured Image Meta Box on Editor Screen
- Add item to top of menu using a filter in functions.php
- Excecuting php function in shortcode
- Only first shortcode gets executed
- Multiple do_shortcode in page template
- How to determine if the sidebar is empty? Or not active?
- Add filter multiple times using only one master function
- How to edit php code in WordPress Post file?
- How to make widget title accept php?
- Change page title from page using php via php executed from page/post itself
- How to make modifications only to certain elements of an HTML string on the server-side?
- Returning data instead of echoing/printing
- Override a function defined in wp-includes/comment-template.php
- echo something inside a shortcode
- displaying content that includes shortcodes within an echo
- Is it bad to add html to a widget by closing and reopening the php tags?
- List taxonomy term slugs within shortcode (do_shortcode)
- Shortcode from a function not working
- Display Data in Table from External Database in WP using Shortcodes
- get_posts works in the page template but not in a shortcode
- Is it possible to return content, and then also continue to do other things?