0

I was looking at this website: https://chandanpandey.com/author/irinampapuc/page/2/ and one of the PHP code solutions in it is nagging at me. The problem is How would you change all the occurrences of “Hello” into “Good Morning” in post/page contents, when viewed before 11AM? The author has an answer that looks like this:

<?php

function replace_hello(){

}

I have Googled this function and the only function I know of that can replace a string is the PHP str_replace() function.

Can anyone confirm the above function is an actual function? In other words is function replace_hello() or function replace_welcome() actually a valid function and where (if at all) in the WordPress Codex or any documentation can I locate to learn more about it?

2
  • This is custom function the author uses to show how to use the_content filter. If you look at the line after the function add_filter('the_content', 'replace_hello');, this is saying to call the custom function replace_hello when encountering the the_content filter Commented Mar 7, 2017 at 20:05
  • @czerspalace, please post your response as an answer and thank you.
    – Daniel
    Commented Mar 7, 2017 at 20:11

1 Answer 1

0

This is custom function the author uses to show how to use the_content filter. If you look at the line after the function add_filter('the_content', 'replace_hello'); this is saying to call the custom function replace_hello when encountering the the_content filter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.