Exercise 1: A the_title Filter That Forgets to Return — Possible Solution ==================================================================== WHAT VISITORS WOULD ACTUALLY SEE ------------------------------ Every post title on the site would disappear entirely, rendered as blank/empty text instead of the intended "Post Title — Read More." WHY THIS HAPPENS, PER THIS CHAPTER'S OWN WARNING ------------------------------ Per this chapter, "a filter function that forgets to return a value doesn't leave the data unchanged - it silently replaces it with null, since a PHP function with no explicit return implicitly returns nothing." the_title is a filter, per this chapter's own compare table "the hooked function must return a value - WordPress uses whatever comes back." The developer's function received the original title as its parameter, presumably built the modified string internally (with " — Read More" appended), but without an explicit return statement, PHP itself implicitly returns null from that function regardless of what was computed inside it. WHY THIS ISN'T "THE TITLE STAYS UNCHANGED" - A COMMON WRONG ASSUMPTION ------------------------------ A developer might reasonably (but incorrectly) assume that forgetting to return would just mean "nothing happens" - the title staying as it originally was. That's not how filters work: WordPress doesn't fall back to the original value if the filter function doesn't return one - it takes WHATEVER the function returns, including nothing (null), and uses that as the new value going forward. Since null is not a missing title but the actual replacement content for the title field, every title filtered through this broken function ends up displayed as empty. WHY THIS MATTERS AS A GENERAL PRINCIPLE FOR EVERY FILTER ------------------------------ This same failure mode would apply to any filter, not just the_title - per this chapter's own example, "a filter hooked onto the_content that echoes debugging output instead of returning the (possibly modified) content will wipe out every post's body text entirely." The lesson generalizes: any filter function without an explicit return statement destroys the data it was supposed to modify, regardless of which specific hook it's attached to. WHY THIS WORKS AS AN ANSWER ------------------------------ It states the concrete visible outcome (blank titles, not unchanged ones), explains the underlying PHP mechanism (implicit null return) using this chapter's own explicit warning, and corrects the natural but wrong assumption that a missing return simply leaves data untouched.