Hashtags in PHP
Working on a project today I had a few tasks to accomplish in PHP, specifically WordPress which I love to use for side-project sites due to its flexibility.
Even though I’m not a fan of its code quality, I do admire how easy it is to do basically anything and customize anything with the use of filters and actions.
So first up I needed to convert a plain text string into a hashtag. For example, “Make America Great Again” should become #makeamericagreatagain.
Next up, if we wanted to automatically hyperlink any hashtags in a paragraph to Twitter searches.
Two simple, but effective functions.
Related Articles
How to lazy load images in React using react-lazy-load-image-component
Boost Your Next.js Lighthouse Score with Lazy CSS Loading.
Start Creating Freedom today
Learn to build fast, scalable SaaS as I document my journey towards freedom. Follow along for real-world lessons and insights from my experiences.