replacing a tag with a function
-
i’ve read the plugin api docs, plugin guidelines, php.net documentation on preg_replace etc, but i still can’t figure out how to do a very simple thing in a plugin:
i need to have a post include a special tag which will be replaced by the result of a simple function, for example:
This is an [specialtag:variable1,variable2] example.
i figured out (mostly) how to replace the tag using the_content filter with preg_replace. i think i’ll figure out how to extract the variables from it, too. but what is the syntax which allows replacing the entire tag with the result of a custom function?
i tried this:
$content = preg_replace_callback("/string/",hello_world(),$content);
but what this does is print the result of
hello_world()
at the top of the content, instead of replacing the string.thanks for any help.
- The topic ‘replacing a tag with a function’ is closed to new replies.