I am reading your book on plugin development. In chapter 2 , you discuss [ accepted arguments] , when referring to the add_filter function, on page 41. I am trying to write a filter which similar to the example on page 40 (Wdiggthis_content filter), except that I would like to pass in a variable to add to the content, so I need to set [ accepted arguments] to 2. I don't know how to do this. When I try:
I read the attached link, but I'm not sure where to go from here. I am still getting the above error and I don't know how to pass in a second argument as far a syntax goes. Can you tell me how to insert the second argument into the lines:
add_filter('the_content', printkeyword, 2, 2);
function printkeyword($text, $keyword2)
Also what did you mean by " Generally you wouldn't need to "
Not sure what you are trying to achieve here, the_content filter passes only one argument anyway and that is the content text. I do not see how can you utilize another argument for that purpose there.
Vladimir’s WordPress Forum
wordpress filter filter hooks
19:20
7 October, 2010
KC
Hello,
I am reading your book on plugin development. In chapter 2 , you discuss [ accepted arguments] , when referring to the add_filter function, on page 41. I am trying to write a filter which similar to the example on page 40 (Wdiggthis_content filter), except that I would like to pass in a variable to add to the content, so I need to set [ accepted arguments] to 2. I don't know how to do this. When I try:
function printkeyword($text, $keyword2) {
$text = $text . $keyword;
return $text;
}
I get an error:
'Warning: Missing argument 2 for printkeyword()"
Thank you in advance,
KC
15:50
8 October, 2010
Vladimir
posts 707
Generally you wouldn't need to
Check http://core.trac.wordpress.org…..cket/14671
20:04
8 October, 2010
KC
Hi Vladimir,
I read the attached link, but I'm not sure where to go from here. I am still getting the above error and I don't know how to pass in a second argument as far a syntax goes. Can you tell me how to insert the second argument into the lines:
function printkeyword($text, $keyword2)
Also what did you mean by " Generally you wouldn't need to "
I apologize , but I am new to PHP and wordpress.
Thank you,
KC
0:39
13 October, 2010
Vladimir
posts 707
Post edited 0:39 – 13 October, 2010 by Vladimir
Not sure what you are trying to achieve here, the_content filter passes only one argument anyway and that is the content text. I do not see how can you utilize another argument for that purpose there.
22:43
13 October, 2010
KC
Thank you for clarifying that. My apologies, I am not a professional so it was not obvious to me.
KC