My Wordpress mods (EN)

Of course the first thing I did after my switch to Wordpress was to start modifying it. I decided to document my changes as a reminder to myself, and then I decided to publish it. This way some people can get hints on how to do this stuff, while other people can give me hints on how to do this stuff a better way.


I made a new header-image (by editing the existing) and uploadet into the same folder (wordpress/wp-content/themes/default/images), with a new name (myheader.jpg). Then I changed the filename in style.css:

#header {
    background: #73a0c5 url('images/myheader.jpg') no-repeat bottom center;

To make the title “centered” correctly I had to modify style.css again, making space for the logos:

h1 {
    font-size: 4em;
    text-align: center;
    padding-left: 165px;
    padding-right: 310px;

Table Of Contents (TOC)

On large blog-entries pages (like this) I have a table of contents. This is generated by a plugin, Table of Contents Generator by Scott Yang. It’s not it the officielt Wordpress plugin repository, but it’s my favorite anyway. It’s simple, and it doesn’t make me insert code that ruins anything when the plugin isn’t running.

To make it look nice, I added this in style.css:

.toc {
    border: 1px solid black;
    float: right;
    font-size: .9em;
    margin: 0 0 8px 8px;
    padding: 4px 4px 4px 8px;
    text-align: left;
    width: 200px;
.toc ol {
    margin: 0 0 0 16px;
    padding: 0;
.toc ol li {
    margin: 0 !important;
    padding: 0;


I want more than just content on my homepage, I also want a little functionality. See clientinfo for my first (and last?) example. This is how I integrated custom PHP into Wordpress:

  • Created a folder named “php”. The location of this folder is not important to get it to work. I placed it in my websites root directory.
  • In this folder I place my custom PHP, for example “clientinfo.php”.
  • Then modify this file: “wordpress/wp-content/themes/default/page.php” – this is with the default theme. (You can do this with the theme editor.)
  • After the end of the div with class “entry” (to clarify: After the div’s “</div>”-tag) insert code like this:
    <?php if(is_page('clientinfo')) { require_once(getcwd().'/php/clientinfo.php'); } ?>

    Again, this is with the default theme. The exact location may be different with another theme.

But that’s it. I should protect the PHP-folder with .htaccess or something, because clientinfo.php can actually be called directly. It doesn’t matter much right now, but it could turn into a security problem with other PHP-scripts in the future.

The output from the PHP is added below the content I make in the page editor. I guess I could put it above, by inserting before the div in stead of after the div.

Why not make a theme template?

Maybe this would be a better idea. I’m not sure. But I do think this would make it harder to switch theme, which I plan to do. I think this solution is simpler, but I haven’t really looked into theme templates, so it’s just a guess. A theme template seemes more “right”, from the “technical design”-angle. In stead of hard-coding page-id’s, I could just select the right template from the page editor.

Why not use a PHP plugin for wordpress?

I tried this. This is what happened: First wordpress modified my PHP so it wouldn’t work. When I had fixed that, it modified the output, which included some Javascript, which then wouldn’t work. I could have fixed that too, but I realised that it didn’t just change the way my PHP worked, it changed the way all content worked. Maybe it’s changes I want anyway at some point, but it’s just too invasive. This homepage is not about getting some PHP to work, it’s about getting some content online, and a few pages with custom PHP.

Comments on pages

The default theme doesn’t allow comments on pages, just posts. That is easy to correct.

Just like the PHP-stuff above, I edited page.php. In stead of the code snippet shown above, I inserted this:

<?php comments_template(); ?>