How can I use WordPress-like short codes? I am new to Drupal. Previously I was working with WordPress, where you can use short codes for getting plugin functionality for pages.

Is this possible in Drupal as well?

For example in WordPress when editing a blog post I can use this in the editor:

[foobar] // This is a short code.


And here's how it got defined in WordPress:

function foobar_func( $atts ) {
  return "foo and bar";
}
add_shortcode( 'foobar', 'foobar_func' );


How to do that in Drupal?
The Shortcode module provides this functionality, it even has this comment:


  Initial work is based on the Wordpress Shortcode API but was reworked for Drupal.


So I think it's the closest thing you're going to find (although the Drupal 7 version is currently only in alpha).

It's not quite the same as the one in Wordpress from the looks of it. It seems you'll need to define a shortcode for each function that you want to run (using hook_shortcode_info()), or else define a more complex shortcode that will allow the adding of arbitrary functions.

There are a few extension modules included with the main module that look pretty easy to understand so I'd have a look through those to see exactly what you need to do to add your own functionality.