php

You can subscribe to the php tag micro-feed.

WordPress Loop Error Using get_the_terms

If you get this WordPress Loop Error… “Warning: Invalid argument supplied for foreach() in [filepath].php on line [number]” when you try to loop over terms found using the WordPress function get_the_terms, you may find this information useful. It happens when you have a post that hasn’t been linked to any terms… but it caused by […]

WordPress Custom Query Page Size

WordPress normally takes care of queries for you. When it doesn’t, your next port of call is normally WP_Query. After that, you head into nuts-and-bolts mode with a completely custom query using get_posts. When you start taking control over queries, you may hit this common problem with page size. Here is an example of custom […]

Useful Apache Mod Rewrite Rules

I recently migrated my website to a different platform. I anticipated that this would require some redirection rules to send people to the correct content on the new website, but I failed to anticipate that number of links to legacy files (like some jQuery plugins and their static HTML example pages). As a result, I […]

Custom Tasks In Visual Studio Code

I was asked how to create a custom task in Visual Studio Code. It comes with a bunch of built-in tasks that you can add to the tasks.json file – but what if you need something else… The example below enables PHPLint (in a not-very-sophisticated way) – but the technique would work for anything you […]

Writing a Mobile App Using HTML 5

Everyone is keen on writing apps these days. For an organisation, apps are the buzz. For consumers, apps are the convenience. The only problem is that writing apps that target every operating system (and then every version of an operating system that has a wide distribution between versions) can be quite a task. This is […]

Dependency Injection in PHP

Dependency Injection solves the problem of dependencies in complex applications. Because we want to re-use our code rather than duplicate it in many places, we end up with more dependencies in our code, but Dependency Injection can ease the pain of dependencies and also make your code easier to test. One of the most popular […]