Five Easy Dictionary Lookup Shortcodes

by 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.

Code: PHP (plus WordPress)Shortcode: tfd_lookup

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:

Code: PHP (plus WordPress)Shortcode: mwdict_lookup

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:

Code: PHP (plus WordPress)Shortcode: mwthes_lookup

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):

Code: PHP (plus WordPress)Shortcode: dict_lookup

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):

Code: PHP (plus WordPress)Shortcode: thes_lookup

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.

Share This Article: “Five Easy Dictionary Lookup Shortcodes”

(Also Available: Press CTRL+D to Bookmark this Page)

Comments

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

Share Your Thoughts

(Some editor features are restricted unless you're logged in.)

(When replying to a specific comment, your browser may require Shift+Enter instead of just Enter.)


(get a gravatar)


Notify me of followup comments via e-mail. You can also subscribe without commenting.