Vladimir’s WordPress Forum


 
Current User: Guest
Search Forums:


 






Wildcard Usage:
*    matches any number of characters
%    matches exactly one character

wordpress filter filter hooks

Add a New Topic Reply to Post
UserPost

19:20
7 October, 2010


KC

Guest

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:

add_filter('the_content', printkeyword, 2, 2);

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

Admin

posts 707

Generally you wouldn't need to

Check http://core.trac.wordpress.org…..cket/14671

20:04
8 October, 2010


KC

Guest

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:

add_filter('the_content', printkeyword, 2, 2);

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

Admin

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

Guest

Thank you for clarifying that. My apologies, I am not a professional so it was not obvious to me.

KC

Reply to Post

Reply to Topic:
wordpress filter filter hooks

Guest Name (Required):

Guest Email (Required):

HTML Editor
Smileys
Confused Cool Cry Embarassed Frown Kiss Laugh Smile Surprised Wink Yell
Post New Reply

Guest URL (required)

Math Required!
What is the sum of:
8 + 1