2019-04-23, 20:48:06
In the hope this helps others:
Using the add_filter() function
==================================
From the docs section: http://get-simple.info/wiki/plugins:hooks_filters
'content' Will allow you to alter or filter the $content variable.
The function that you pass $content to should then return your results back to the system.
In other words
My interpretation is as follows:
When you use a filter and specify (content,function call) then
the content variable is passed to that function so make sure you include a param variable in your function description.
Once the function searches for the placeholder and replaces the placeholder with your content
then we return the new value back to the filter using the return method.
Big thanks to : smdp-1971 for the example. It really helped.
(I've tweaked the original example so it just outputs something simple.)
PHP Code:
add_filter('content','content_test');
function content_test($content){
$regex = '(%whatever%)'; // add this (%whatever%) to your page to include content
$out = "whatever content- it works!!!";
$content = str_replace($regex, $out, $content);
return $content;
}
Using the add_filter() function
==================================
From the docs section: http://get-simple.info/wiki/plugins:hooks_filters
'content' Will allow you to alter or filter the $content variable.
The function that you pass $content to should then return your results back to the system.
In other words
My interpretation is as follows:
When you use a filter and specify (content,function call) then
the content variable is passed to that function so make sure you include a param variable in your function description.
Once the function searches for the placeholder and replaces the placeholder with your content
then we return the new value back to the filter using the return method.
Big thanks to : smdp-1971 for the example. It really helped.
(I've tweaked the original example so it just outputs something simple.)