Wordpress doesn't like headers/classes/anything?!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Wordpress doesn't like headers/classes/anything?!

Post by JAB Creations »

The third piece of blog software I'm messing with today: Wordpress. While it has a PHP XHTML template which lets me include XHTML template material it absolutely outright refuses to even let me use my own class file! It does nothing but declare classes! :roll: Can any one please shed some light on this issue please?
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Wordpress doesn't like headers/classes/anything?!

Post by JAB Creations »

The first post I have mostly resolved, it turns out I was doing a double includes so my goof.

Now I'm dealing with Wordpress's clientside templating allows me to use PHP includes...the only problem is that on my site all the XHTML template files see the classes and just work. However when I include those same XHTML template files (mostly chunks of XHTML code) they can't see the class declarations. If I include the class file in the footer for example Wordpress generates a blank page...well this is because the classes are declared twice...I think. I never found a way to prevent classes from executing if the headers were sent (headers_sent won't help here that I know of) and require didn't seem to do the trick. Suggestions?
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Wordpress doesn't like headers/classes/anything?!

Post by JAB Creations »

Some times people makes the most difficult situations out of the most simple scenarios...having a whole function setup when all WordPress had to do was an include!

Open the WordPress theme folder, open index.php, and comment out the header and footer functions and for goodness sakes...just include it's own the header and footer! Then include your own PHP header file. Here is the general overview of what the code should look like...

Code: Select all

include("../../../my_own_custom_header.php");
//get_header();
include("header.php");
...content of the index.php file, towards the bottom do the following...

Code: Select all

// get_footer();
include("footer.php");
Hope this helps other people out there!
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Re: Wordpress doesn't like headers/classes/anything?!

Post by jmut »

Your definately doing something wrong. This seems like really hackish solution, did you read documentation on howto dev over wordpress?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Wordpress doesn't like headers/classes/anything?!

Post by Chris Corbyn »

jmut wrote:Your definately doing something wrong. This seems like really hackish solution, did you read documentation on howto dev over wordpress?
I agree. Although wordpress isn't perfect it's actually pretty well written compared to many other open source PHP apps of the same age. Using abstraction is a good thing, it's not a "difficult situation of out of a simple scenario". I'd probably undo your change and do some reading around so you can implement it cleanly.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Wordpress doesn't like headers/classes/anything?!

Post by JAB Creations »

They are only XHTML template files that include PHP files on occasion, it's not like I had to go to non-template files and start adjusting anything. I think it was just that particular template where the guy probably copied and pasted the function instead of doing an includes.

Oh wait I did have to go in to non-template files to adjust XHTML that should not have been present there. Though I could not expect perfection of XHTML code being located only in template files right? Any way things are going as smoothly as I could expect it to go.

Any way I presume an includes creates less load then processing a function? I mean after all why execute a function to determine what theme folder the file is in when the including file and the included file are in the exact same directory?
Post Reply