Created
September 13, 2017 18:16
-
-
Save cobaltapps/18e8530a4d385e203c89168842322f5a to your computer and use it in GitHub Desktop.
A simple example of how to filter a custom value into an applied filter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This is the cleanest way to do this, using an anonymous function, | |
* but such a function requires PHP 5.3 or higher. | |
*/ | |
add_filter( 'theme_read_more_text', function() { return 'Read more ->'; } ); | |
/* | |
* This is the same anonymous function example, | |
* but formatted differently for those who might | |
* the first example a bit confusing. | |
*/ | |
add_filter( 'theme_read_more_text', function() { | |
return 'Read more ->'; | |
} ); | |
/* | |
* This example is the more "traditional approach | |
* using a named function for pre-5.3 PHP compatibility. | |
*/ | |
add_filter( 'theme_read_more_text', 'my_custom_read_more_text' ); | |
function my_custom_read_more_text() { | |
return 'Read more ->'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment