Five Easy Dictionary Lookup Shortcodes
by Luke America on March 12, 2011
Last month, we introduced two shortcode lookup utilities … one was for php keywords and the other was for WordPress keywords. Today, we've got some easy online dictionary and thesaurus lookups.
These can be especially useful for literary blogs. But, you might want to make use of them anytime you have an unusual word in one of your posts. Sometimes, we bloggers can be word slingers.
For each of these shortcodes, there is no attribute name. This is a major convenience. You simply type the word to lookup immediately after the shortcode name.
For example, using the TheFreeDictionary.com, our code would look like this:
[tfd_lookup spectacular]
The blog output would be:
spectacular
This site lists both the definition and the synonyms for a search term on the same page. Our other two use a separate shortcode for the thesaurus.
1 2 3 4 5 6 7 8 | add_shortcode('tfd_lookup', 'tfd_lookup_shortcode_handler'); function tfd_lookup_shortcode_handler($atts) { $keyword = $atts['0']; $output = '<a href="http://www.thefreedictionary.com/' . $keyword . '" target="_blank">' . $keyword . '</a>'; return $output; } |
Merriam-Webster Dictionary:
1 2 3 4 5 6 7 8 | add_shortcode('mwdict_lookup', 'mwdict_lookup_shortcode_handler'); function mwdict_lookup_shortcode_handler($atts) { $keyword = $atts['0']; $output = '<a href="http://www.merriam-webster.com/dictionary/' . $keyword . '" target="_blank">' . $keyword . '</a>'; return $output; } |
Merriam-Webster Thesaurus:
1 2 3 4 5 6 7 8 | add_shortcode('mwthes_lookup', 'mwthes_lookup_shortcode_handler'); function mwthes_lookup_shortcode_handler($atts) { $keyword = $atts['0']; $output = '<a href="http://www.merriam-webster.com/thesaurus/' . $keyword . '" target="_blank">' . $keyword . '</a>'; return $output; } |
Dictionary.com (two shortcode names):
1 2 3 4 5 6 7 8 9 | add_shortcode('dict_lookup', 'dictionary_lookup_shortcode_handler'); add_shortcode('dictionary_lookup', 'dictionary_lookup_shortcode_handler'); function dictionary_lookup_shortcode_handler($atts) { $keyword = $atts['0']; $output = '<a href="http://dictionary.com/browse/' . $keyword . '" target="_blank">' . $keyword . '</a>'; return $output; } |
Thesaurus.com (two shortcode names):
1 2 3 4 5 6 7 8 9 | add_shortcode('thes_lookup', 'thesaurus_lookup_shortcode_handler'); add_shortcode('thesaurus_lookup', 'thesaurus_lookup_shortcode_handler'); function thesaurus_lookup_shortcode_handler($atts) { $keyword = $atts['0']; $output = '<a href="http://thesaurus.com/browse/' . $keyword . '" target="_blank">' . $keyword . '</a>'; return $output; } |
Choose your favorite one or two and put them in your theme's functions.php file.

Subscribe to our RSS feed
Follow Us on Twitter


Comments
Share Your Thoughts One Response to “Five Easy Dictionary Lookup Shortcodes”