Accessing WordPress data from outside WordPress

(img by shindohd)

There are times when you want to access the data from your WordPress database from a webpage outside of your WordPress installation. This can be done by using the mysql_connect of PHP and selecting the data with some genuine SQL statements. This will work but it has the substantive disadvantage that the WordPress database is changed now and then and that the SQL statement will fail sooner or later.

There has to be a better solution and there is one! Simply use the function provided by WordPress itself to access the data. It’s as simple as this code:

include '../blog/wp-blog-header.php';

In this example WordPress is installed in the directory “../blog” relative to the directory of the current script. You have to adapt it to your installation, of course. Now you can access the database using the $wpdb-instance, i.e.

$post_id = 666;
$sql = "select post_title from $wpdb->posts where ID=$post_id";
$title = $wpdb->get_var($sql);

Ok, if Automattic decides to change the row names you’ve lost again. So you should completely avoid direct database calls and use the functions build into WordPress which are also available after including the above file:

$post_id = 666;
$title =  get_the_title($post_id);

This should be a safe call for a very long time!

First meeting for launching a hackerspace in Kassel/Germany

Kassel, a city located at the Fulda, population 200,000, is as ugly as sin but it’s got the <a href="Herkules, a pile of museums, a great hackerspace, a national theatre, a university

Wait, wait, wait! A hackerspace? In Kassel? No, of course there isn’t one. Not yet. But there could be soon. Some people thought they could change this state and create such a space in Kassel, whereby space does not exclusively has to be taken as a physical room.

So the call went out into the great wide open of the Internet and the initiators hoped for a small group of interested people. at the first meeting in a small pub this small group turned out to be a large group of 28 combatants.

Unfortunately the locality was quite unsuitable for such a large group. If only five or ten people had shown up it would have been a nice and cosy get-together but actually we had to make the best of the circumstances. Some verbal contributions could hardly be heard others not at all. But nobody could expect such an immense interest. Nonetheless everybody was concentrated and the discussion was quite constructive. After a short introduction to the basic ideas of hackerspaces everyone told a bit about his background, his intentions, ideas, and expectations. I think a lot of Blinkenlights will be created in the near future.

Obviously there is a great crowd of hardware freaks, programmers, and artistically interested men (yes, there wasn’t a single woman) having many ideas for new and/or interesting projects  and ideas how they can help others and how others can help them. The initiators presented a welled planned  concept and even looked after some affordable rooms with a good infrastructure. Next week we will have a go and see.

Hopefully everybody will keep at it and the new hackerspace will have a good substantial and financial foundation. It’s going to be interesting!


Botany Bay: Old Men with Ballpoint Pens

Botany Bay made a nice music clip about surveillance. You may not know the people in the clip (German politicians) but that does not matter at all.

Old Men With Ballpoint Pens

They know it is the worst thing
Not being in control
So they bring in all the big guns
To ease their troubled souls
You can see them in the tabloids
Where they smile their empty smiles
Selling tales of lawless chaos
And lies upon lies
They waste no time, they’re on the way
They’re quick to bend the laws
To abuse the ones who suffered
For their twisted cause

Old men with ballpoint pens
Old men with ballpoint pens
Old men with ballpoint pens
Old men with ballpoint pens

They know what you’ve been doing
They know where you have been
They read the words, both yours and mine
They’ve seen what you have seen
They’re here to protect you
All for the common good
Don’t you dare to get in their way
They just know what’s good for you
And if you’re feeling watched
And if you’re full of fear
Remember that, remember how
It was you who brought them here

Old men with ballpoint pens…