Add the following function into your newly written plugin (or functions.php file of your theme), to correct misspellings of wordpress to WordPress:

function thefirst_content_replace( $content ) {
    return str_replace( ‘wordpress’, ‘WordPress’, $text );
add_filter( ‘the_content’, ‘thefirst_content_replace’ );

thefirst_content_replace is the unique name we’ve given our function. When adding new functions never start them with wp_ – this to prevent any future incompatibilities with WordPress code functions which all use the prefix wp_.

Our PHP function takes ( $text ) as the argument, and returns the 1st string ‘wordpress’ replaced with the 2nd string ‘WordPress’.

We’ve added a filter ( add_filter ) to our plugin to tell our function ( thefirst_content_replace ) to work on the text we’ve selected, which in this case is the entire post content ( the_content ).

Related Posts
Leave a Reply

Your email address will not be published.Required fields are marked *