Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QUESTION Using (%%)
#9
In the hope this helps others:

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.)
Reply


Messages In This Thread
Using (%%) - by craiga - 2019-02-23, 22:58:57
RE: Using (%%) - by datiswous - 2019-02-27, 23:10:42
RE: Using (%%) - by craiga - 2019-03-01, 22:49:39
RE: Using (%%) - by craiga - 2019-04-23, 00:14:43
RE: Using (%%) - by datiswous - 2019-04-23, 06:56:30
RE: Using (%%) - by craiga - 2019-04-23, 08:05:04
RE: Using (%%) - by smdp-1971 - 2019-04-23, 08:29:54
RE: Using (%%) - by craiga - 2019-04-23, 17:18:40
RE: Using (%%) - by smdp-1971 - 2019-04-23, 22:11:38
RE: Using (%%) - by craiga - 2019-04-23, 20:48:06
RE: Using (%%) - by shawn_a - 2019-04-26, 02:46:42
RE: Using (%%) - by craiga - 2019-04-29, 18:50:02
RE: Using (%%) - by shawn_a - 2019-05-04, 08:51:08



Users browsing this thread: 1 Guest(s)