If I put a function that I want to use in a template I can put it into functions.php
function myfunction(){
echo 'My String';
}
add_action('myfunction','myfunction');
and in a template file put:
do_action('myfunction');
This appears to only work if writing something out to the screen. If I wanted to return a variable instead to the page. E.g.
function myfunction(){
return 'My String';
}
$string = do_action('myfunction');
and capture it instead of print it. How would I do it?
There’s filters for that.
Example:
Then in your template just add in the defaults:
More info in Codex about the Plugins API.