Wordpress widget / plugin - visible content based on text messages / pages (s)?

I am new to Wordpress plugin and API widgets, but I'm sure it is possible.

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

Is it possible?

For example, if the term is in all caps, refer to the definition of a Wiktionary; within the <news>..</news> pair, go to Google News Search; and etc.

0
source share
1 answer

It is definitely possible. Do not look at the api widget for this. Take a look at the api filter. WordPress has an api that allows you to filter content before it is sent to the browser. In this case, you would do something like this:

 function my_super_awesome_content_filterer( $content ){ $content = preg_replace( '#([AZ]+)#', '<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

+1
source

Source: https://habr.com/ru/post/1337973/


All Articles