Getting the post ID from a WordPress content on an external site

In case you need to get the post/page/{$custom_type} ID from a WordPress content, from a remote site or no direct access to the database, here’s an easy and reliable way to do it.

When you make a request to a WordPress site for a “singular” content (that is, the detailed view of a single post, whatever type it is), you should receive a Link HTTP header that uses the database ID of the content, something like:

Link: <{$POST_ID}; rel=shortlink

From then on, you can extract the {$POST_ID} param from the URL using your favourite technique.

If you do have access to the database, you might want to check this post: How to Get Post and Page IDs in WordPress.

Can complexity emerge from lower levels of simplicity?

‘Is there really a Universe that is not designed from the top downwards but from the bottom upwards? Can complexity emerge from lower levels of simplicity?’ It has always struck me as being bizarre that the idea of God as a creator was considered sufficient explanation for the complexity we see around us, because it simply doesn’t explain where he came from. If we imagine a designer, that implies a design and that therefore each thing he designs or causes to be designed is a level simpler than him or her, then you have to ask ‘What is the level above the designer?’ There is one peculiar model of the Universe that has turtles all the way down, but here we have gods all the way up. It really isn’t a very good answer, but a bottom-up solution, on the other hand, which rests on the incredibly powerful tautology of anything that happens, happens, clearly gives you a very simple and powerful answer that needs no other explanation whatsoever.

Douglas AdamsSpeech at Digital Biota 2

What is code? It’s not magic, just work

It’s very likely that you already know about or even read the latest issue of Bloomberg, entirely dedicated to answer What is Code? — if you haven’t, you definitely should go read it.

The entire piece is informative and fun to read, and there’s probably something new for everyone reading it. My favourite highlight is:

Computing treats human language as an arbitrary set of symbols in sequences. It treats music, imagery and film that way, too.

It’s a good and healthy exercise to ponder what your computer is doing right now […]

Thinking this way will teach you two think about computers: one, there’s no magic no matter how much it looks like there is. There’s just work to make things look like magic. And two, its crazy in there.

Which reminded me something I said to a fresh group of designers on a HTML+CSS+Javascript crash course.

Horizontally scaling PHP applications

One of the most common worries of the enterprise IT world about WordPress and other Open Source apps it’s how you can scale it — which it’s kind of ironic when their enterprise-y web services response times are usually measured in the scale of tens of seconds…

DigitalOcean has published a high-level practical-overview on horizontally scaling PHP apps that’s a good starting point and I guess it could also apply to other kinds of apps as well.

Debugging memory usage in PHP apps

As your app gets increasingly more complex, you might run into Memory exhausted errors, and even though you can always increase the allowed memory usage — either by tweaking php.ini or locally with ini_set() — it should be a better option to find out what’s using so much memory in the first place.

Continue reading “Debugging memory usage in PHP apps”