Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

cleo

macrumors 65816
Original poster
Jan 21, 2002
1,186
0
Tampa Bay Area, FL, USA
I'm writing a WordPress plugin that is also my first foray into writing my own PHP functions. (I've been using PHP for 6 years, but was always too intimidated to try my hand at custom functions.)

Anyway, it's pretty simple, and sometimes works fine, but more often than not I get the following error:

Code:
Fatal error: Maximum execution time of 30 seconds exceeded in /home/gobecky/public_html/gobecky-net/wordpress/wp-includes/plugin.php on line 274

The script referenced is one of the core WP files, and I haven't touched it in any way. It's clear that it's my plugin, though, because removing the function call lets the page load just fine.

For the sake of a short post, here's a link to my script: plugin.txt

And here's how I'm calling it:

Code:
prevNextByCat('','','<div class=\'chunk\'><ul>','</ul></div>','<h3><span>Browse</span> / in ','</h3>');

Any insight would be much appreciated!
 
Ugh, what awful plugin code (my .02) - let me explain:

The plugin checks all your categories against the current post running two relatively complex queries for category if a match is made or not. It should probably be running one consolidated query, not returning all fields (only what is needed) in the result set and those pesky left joins might not even be required - that slows things down right there. I cannot suggest a new query or code because I don't use wordpress, I'm just reporting to you that looping through stuff with two bloated queries on every page load is always wrong, no matter the application or context.

I suggest you find another version of the plugin that works better or code your own solution. Maybe some wordpress guru can help ya. I'm just pointing out the "why" although I can't code a "fix" as I am unfamiliar with the entire database structure and overall code base.

-jim
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.