Posts with tag: Snippets

Creating shortcodes in WordPress

WordPress shortcodes are a handy way to add standardised or dynamic content to any post or page. Once you have used them for a bit you will start to realise just how powerful they really are. Here is a guide on how to create shortcodes that you (or your clients) can use.

Leave a comment Continue Reading →

Loop through each character in a string in PHP

The other day I was working on a project that required me to extract a numeric ID from the current page’s URL. The problem was that the ID could either be at the end of the URL string or in the middle, depending if there were any parameters added on or not. Here is how I worked around the problem by looping through each character of the string.

Leave a comment Continue Reading →

Code Snippet: A custom Twitter feed for your website

If you’re using a CMS you can simply find a handy plugin that displays your Twitter feed on your site, but if you’re working in a non-CMS framework then it’s more tricky. Here’s a handy piece of code you can use to get your twitter feed as well as any tweets that mention your name. I have also provided a simple function that uses regex to turn any URLs, hash tags or @mentions in your tweets into clickable links.

13 Comments Continue Reading →