Programming

WordPress Loop Error Using get_the_terms

Posted on

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 […]

CMS

WordPress Custom Query Page Size

Posted on

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 […]

Programming

Signs You Broke the Interface Segregation Principle

Posted on

I have written quite a lot about how to follow SOLID principles, but one thing that can be useful is examples of where a principle is not being followed. What does your code look like when it wants to tell you something? Here are the signs that you broke the Interface Segregation Principle (ISP). Here […]

Programming

Useful Apache Mod Rewrite Rules

Posted on

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 […]

Visual Studio

Custom Tasks In Visual Studio Code

Posted on

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 […]

Programming

Writing a Mobile App Using HTML 5

Posted on

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 […]

Programming

Dependency Injection in PHP

Posted on

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 […]