Passing an argument to add_filter
-
Hi folks,
I’m trying to pass an argument to the add_filter function to display dynamic content in the loop. When I do, the page renders incorrectly with the function’s content displayed at the top of the page, instead of in the post area.
The code without an argument displays in the post area correctly:
add_filter('the_content', 'DisplayMe'); function DisplayMe($argument) { print "The argument will go here: "; }
I’ve checked the add_filter and related docs here.
..and this post looks like a helpful solution and it does pass the argument successfully. But now all the data is rendered at the top of the page and not in the post/loop area.
The code suggested above that does pass argument but renders at top of page:
add_filter('the_content', DisplayMe('argument'),1); function DisplayMe($argument) { print "The argument will go here: ". $argument; }
It seems like I’m missing something easy here. It acts as if I’ve introduced (or omitted) a table tag or some such.
Any input appreciated!
Best,
Mark
- The topic ‘Passing an argument to add_filter’ is closed to new replies.