WordPress: Solution for Nicer Archives mod problem

Posted by Pierre Igot in: Blogging
January 25th, 2005 • 7:58 am

Well, Mark Ghosh, the author of the Nicer Archives mod discussed earlier today, did get back to me today, which was greatly appreciated. And together we were able to identify what the problem was.

It turns out that, in the process of customizing his Nicer Archives mod in order to make it look like my other pages, I copied some code that I should not have included. The offending code was this:

<!--
<?php 
/* Don't remove this line. */
require('./wp-blog-header.php');
?>
-->

Without the comment tags (<!-- and -->), this is the code that is supposed to appear at the very top of each PHP file that is used to access the WordPress data. The reason I commented it out is because Mark’s mod includes its own require command at the very top of the page, which is:

<?php require('wp-config.php'); $single = 1; $siteurl = get_settings('siteurl'); ?>

I had enough savvy to realize that this replaced the default require command, which is why I commented it out. What I didn’t realize, obviously, was that commenting out HTML code and commenting out PHP code are not the same thing.

In order to comment out PHP code, you need to add a double slash (//) before it. And apparently, commenting out with the HTML comment tags HTML code that includes PHP code does not comment out the included PHP code, which is still parsed and processed by the server.

I added a couple of slashes before the PHP code — et voilà! Everything was working fine now without my “nolimit” hack!

Phew! What a day :). I have wasted quite a bit of time designing this hack that turns out to be useless, but at the same time I have learnt quite a few things about PHP, so it’s not entirely wasted. Still, this PHP stuff is not for the faint-hearted!


Comments are closed.

Leave a Reply

Comments are closed.