Comments on: Adding Functionality with functions.php, a Heart of WordPress Theme Development https://wpshout.com/wordpress-functions-php/ A hub for advanced WordPress users, developers & savvy business owners. Wed, 13 Mar 2019 17:02:39 +0000 hourly 1 https://wordpress.org/?v=6.4.3 By: Fred Meyer https://wpshout.com/wordpress-functions-php/#comment-21245 Fri, 20 Jul 2018 13:44:41 +0000 https://wpshout.com/?p=3463#comment-21245 In reply to Yves.

Hi Yves, Sure!

The third argument, 10, is priority: what order this filter function will execute relative to all the other filter functions hooked to the same filter.

So if there was another function that looked like this:

add_filter('get_bsearch_excerpt', 'another_custom_function', 9, 4);

Then it would execute before the function you typed out above. And another function:

add_filter(‘get_bsearch_excerpt’, ‘yet_another_custom_function’, 11, 4);

Would execute after both of those functions. In general, functions with larger numbers are more “important,” because they’re the last ones to act on or filter WordPress’s output, after all other similar functions have already run.

The fourth argument, 4, refers to how many arguments the filter function is passing along. Whoever wrote the apply_filters() call for get_bsearch_excerpt() indicated that that filter could pass along at least 4 arguments for any filter function to work with. The 4 in the text you pasted in indicates that you’ll take the first 4 of those arguments to actually work with. If you wrote 1 instead, it means you’re only bringing in the first argument of the ones that the filter makes available.

Hope that helps!

]]>
By: Yves https://wpshout.com/wordpress-functions-php/#comment-21244 Wed, 18 Jul 2018 00:08:56 +0000 https://wpshout.com/?p=3463#comment-21244 Great guide. Thanks!
I have the feeling that you are the one who could tell me what is the use of the “10,4” part, in this:
add_filter(‘get_bsearch_excerpt’, ‘get_custom_bsearch_excerpt’, 10, 4);

?

Would be greatly appreciated.
I have been searching for the answer for a long time.

Thanks!

]]>
By: Mr. KingsHOK https://wpshout.com/wordpress-functions-php/#comment-21243 Tue, 17 Jul 2018 16:28:23 +0000 https://wpshout.com/?p=3463#comment-21243 Thanks for this guide. But what’s the difference between using snippet plugin and using direct function.php coding to activate a feature in wp?

]]>