How to pass parameter in wordpress url?

How do I pass an additional parameter to apply_filters() in WordPress?

  • The second parameter, $argument, does not seem to be passed to the function hooking the filter.  I expected "Hello World!" would be displayed but only "Hello" was displayed. <?php /* Plugin Name: Apply Filters Demo */ add_action('admin_init', 'apply_filters_demo'); function apply_filters_demo() { $string = 'Hello'; $argument = 'World!'; $string = apply_filters( 'my_filter_hook', $string, $argument ); echo '<div class="updated">' . $string . '</div>'; } add_action('my_filter_hook', 'apply_filters_myfunc' ); function apply_filters_myfunc($string, $argument='') { return $string . ' ' . $argument; }

  • Answer:

    I guess there is a problem with your add_action function. add_action takes 4 variables. The first and second are required. name of the filter, name of the function. priority (when does the function gets fired). Amount of parameters. So the modification must be something like this. add_action('my_filter_hook', 'apply_filters_myfunc' ,10,2); function apply_filters_myfunc($string, $argument='') {     return $string . ' '  . $argument; } Hope this works for you. ----------------------------- http://www.sachingkulkarni.com/

Sachin G Kulkarni at Quora Visit the source

Was this solution helpful to you?

Other answers

Do you have a WordPress issue that is driving you mad? If so let us fix it for you. We will fix any single issue for only $27. If we can’t fix it we will refund your money. You have nothing to lose! Just take a tour something amazing awaits for you http://wphotfix.com/

Imran Hossain

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.