views:

17

answers:

1

I'm new to the Wordpress plugin and widget APIs, but I'm sure this is possible.

I'd like to make a plugin or widget that would create links to other posts or external sites based on certain keywords/tags in the content of the given page/post.

Is this possible?

For example, if a term is in all-caps, link to the Wiktionary definition; inside a <news>..</news> pair, go to Google's news search; etc.

+1  A: 

This is definitely possible. Don't bother looking into the widget api for this. Look at the filter api. WordPress has an api that allows you to filter content before it's sent to the browser. In this case, you'd do something like this:

function my_super_awesome_content_filterer( $content ){
  $content = preg_replace( '#([A-Z]+)#', '<a href="wictionary.definition.address=$1">$1</a>', $content );
}

add_filter( 'the_content', 'my_super_awesome_content_filterer' );

Read more about filters here:

http://codex.wordpress.org/Plugin_API#Filters

John P Bloch
that's what I wanted! Thanks, John!!
warren