Everyone on internet knows about smilies or emoticons. Smilies basically add emotions and expressions to write-ups. WordPress too, provides a basic set of over 20 smilies to its users to use on their blogs. Some of the commonly used WordPress smilies are smile :), tongue :P, laughter :D. To know more about these basic WordPress smileys and their usage, see this document.
Now, what if I want to add my custom smilies to WordPress, each with a separate text-representation or punctuation marks (eg. :-) for :-))? The rest of this article covers the answer to this question.
Can I add my own smilies to WordPress?
Yes, you can, and it’s not so difficult to accomplish. You may use a plugin to achieve that or may do it manually.
WordPress Plugins to add custom smilies
Have not tested this plugin, but have heard from most of the users about it. It’s Custom Smilies plugin and here is a screenshot take from it’s support page:
So, go, install and give the plugin a test shot.
Manually adding custom smilies to WordPress
So, to add new smilies to WordPress, all you need is to add your custom smilies in WordPress smilies folder (each with a different file name than the existing standard WordPress smilies), and then modify some code to provide our custom smilies a unique text-representation. So, here we go.
Upload your smilies to WordPress smilies folder
- Navigate to the
wp-includesfolder in your WordPress (you can do this with the help of an FTP client like FileZilla, WinSCP etc.) The
wp-includesfolder is located in WordPress root.
- Now, in
wp-includesfolder, go to the
imagesfolder, look for the
smiliesfolder in it (that contains all the default smilies that are being used on WordPress). Now upload your new smiley files in this smilies folder. Note: Consider using .gif, .jpg or .png files only for the smilies. Keep the name of your smiley files different from the standard WordPress smilies.
Give your smiley a unique punctuation
Now comes the coding part. No, you don’t have to code anything but to modify the existing code a bit. Lets start.
- In the
wp-includesfolder, look for the
functions.phpfile, search the
smilies_init()function, and spot the array variable
$wpsmiliestransthat contains all of our standard WordPress smilies and their textual punctuation (eg.
- Move to the end of the array on line#2282, and right after the
:?:smiley, add your unique smiley punctuation and smiley file name in the same fashion. See the below screenshot for a better idea:
Note: Keep the new smiley punctuation text unique and different from the existing standard WordPress smiley punctuations.
Now it’s time to test our newly added smiley, which can be done by simply typing the text punctuation for our new smiley in any of our posts. Enjoy :)