Posts Tagged ‘how to’

How to add comments to Wordpress homepage

Tuesday, December 30th, 2008

So, I use Wordpress.  I don’t like Wordpress at all, but I used it at my last job so I got some experience with it and that means that it was easier to just use it and deal with the consequences later.  I wouldn’t recommend it to another developer though, the codebase is truly hideous.

I recently wanted to add comments to my homepage.  I only like to make changes to my template and not to change any Wordpress “core code”, since then I’ll have to make all those changes everytime I update Wordpress.  I didn’t think this policy would be a problem for me this time since all I was trying to do was add the ‘comments template’ to the homepage and I thought that I should be able to just copy the appropriate line from my ’single.php’ into my ‘homepage.php’…  Wrong!   How any ‘non-technical’ person manages to use wordpress is beyond me…

Anyhow, I did some digging and found the problem.  The function comments_template in comment-template.php has these lines:

if ( ! (is_single() || is_page() || $withcomments) )
return;

I’m not going to go into the reason why these lines are harmful but I’ll just say that my argument might be summed up as “hard coded configuration”.  Anyway, these lines in homepage.php will get you what you want:

$withcomments = true;
comments_template();

Or, if you want to be a smartass like myself, this will work too:

$withcomments = “I hate wordpress”;
comments_template();

Cheers!

How to initialize a remote Git repository

Wednesday, September 24th, 2008

Well, since it took me all day to figure this out again, I figured I might as well write it down somewhere so that at least I’ll be able to remember it the next time I want to create a new repo with Git.

The one thing that irks me is that I always try to create a bare repo on the server and then clone it to my client.  For some reason git doesn’t want to work this way even though that’s what my intuition tells me.

Anyway, the way to do it is to first create your working copy.  I’m making a little website so I have some code in /www/my-working-copy.  After you have some code that you want in the repo, you need to initialize a git repository and add your code to it like so:

git init
git add .

After that’s done, you want to go your git-daemon’s base path and clone this repo there with a bare copy:

cd /my-git-daemon-base-path && git clone –bare /www/my-working-copy my-remote-repo

You should get a message like “Initialized empty Git repository in /my-git-daemon-base-path/my-remote-repo/” after which you may need to run update-server-info and you’ll also want to add a ‘git-daemon-export-ok’ file to the repo so that the daemon knows that it is okay to export it:

git update-server-info
cd /my-git-daemon-base-path/my-remote-repo && touch git-daemon-export-ok

At this point you also will most likely want to add a ‘tracked repository’ named ‘origin’ to your working copy so that git will know where you want to push and pull from:

cd /www/my-working-copy && git remote add origin /my-git-daemon-base-path/my-remote-repo

That’s it!  To test it out simply try a commit:

git commit -a

You should receive a message “nothing to commit (working directory clean)”.

At this point you probably want to push your changes to the repo.  Although the repo is created, it won’t be very useful until there’s something in it:

git push origin master

Cheers!