WordPress.org

Ready to get started?Download WordPress

Forums

add_filter: How to pass parameters to functions ? (3 posts)

  1. j8h9
    Member
    Posted 4 years ago #

    So I create a simple plugin to display data via add_filter. I can invoke my php function with add_filter. How can I pass a parameter to my function? One post/page I want to display stats for Red Sox, in another stats for White Sox. I want to call the same function and simply pass a parameter to indicate which stats to display? How? I see in syntax says number of args but how do I pass? Help! Thanks

  2. j8h9
    Member
    Posted 4 years ago #

    Well I am getting the results I want but it doesn't appear I'm doing it the way I should be.

    I installed php_exceution plugin and then put this into each post and it works.

    938<?php add_filter("the_content","myfunction");?>

    Basically, my function finds 938, does a database lookup and returns the correct data (based on the id = 938). Am I suppose to be executing add_filter in each post? Is there an easier way to do this?

  3. takien
    Member
    Posted 4 years ago #

    Hi...
    you can use this..

    add_filter('the_content',your_function($arg1,$arg2),2);

Topic Closed

This topic has been closed to new replies.

About this Topic