Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8991151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:39:37+00:00 2026-06-15T22:39:37+00:00

I’ve read WordPress codex many times but still don’t understand how to return the

  • 0

I’ve read WordPress codex many times but still don’t understand how to return the value if more than one arguments involved. For example:

function bbp_get_topic_title( $topic_id = 0 ) {
    $topic_id = bbp_get_topic_id( $topic_id );
    $title    = get_the_title( $topic_id );

    return apply_filters( 'bbp_get_topic_title', $title, $topic_id );
}

In the above filter, there are 2 arguments. When I add_filter, should I return 2 value, or just return the one I need? Is the following example correct if need the title?

add_filter( 'bbp_get_topic_title', 'my_topic_title', 10, 2 );

function my_topic_title( $title, $topic_id ){
  $title = 'my_example_title';
  return $title;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:39:39+00:00Added an answer on June 15, 2026 at 10:39 pm

    That’s absolutely correct.

    When registering a filter(or basically calling apply_filters), you should call the function with at least two arguments – name of the filter to be applied and the value to which the filter will be applied.

    Any further arguments that you pass to the function will be passed to the filtering functions, but only if they have requested additional arguments. Here’s an example:

    // Minimal usage for add_filter()
    add_filter( 'my_filter', 'my_filtering_function1' );
    // We added a priority for our filter - the default priority is 10
    add_filter( 'my_filter', 'my_filtering_function2', 11 );
    // Full usage of add_filter() - we set a priority for our function and add a number of accepted arguments.
    add_filter( 'my_filter', 'my_filtering_function3', 12, 2 );
    
    // Apply our custom filter
    apply_filters( 'my_filter', 'content to be filtered', 'argument 2', 'argument 3' );
    

    Given the code above, the content to be filtered will be passed first to my_filtering_function1. This function will only receive the content to be filtered and not the additional arguments.

    Then the content will then be passed(after being treated by my_filtering_function1) to my_filtering_function2. Again the function will only receive the first argument.

    Finally the content will be passed to the my_filtering_function3 function(as it has been changed by the previous two functions). This time the function will be passed 2 arguments instead(since we specified this), but it won’t get the argument 3 argument.


    See apply_filters() in source.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I don't have much knowledge about the IPv6 protocol, so sorry if the question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.