4 ms·
The experience I related above took place around 2008/9. Sorry if that's a bit out of date. I looked through your links and it does look like there have been re
by kijin 14y ago
The experience I related above took place around 2008/9. Sorry if that's a bit out of date. I looked through your links and it does look like there have been recent efforts to produce bare-bones themes, though the OP's theme is much better documented. What I really want to see is a version of the Codex that actually guides the user through an exemplary theme, and OP's theme comes pretty close to that.
And yes, I'm referring to the weird `if (have_posts()): while (have_posts()): the_post();` boilerplate. Back then, for a PHP newbie like me, it looked like a magical one-liner ... until I realized that the loop actually terminates hundreds of lines later with an endwhile/endif statement. It's so easy for newbies to miss the significance of the two colons, especially if they're not familiar with the "alternate syntax for control structures".
Although I now understand how the loop works, it still pisses me off that I have to call a function to populate a bunch of hidden variables/objects that are later fetched by other functions. Too much going on behind the scenes == difficult to grok. A simple foreach() loop would have been much more intuitive. Perhaps this will happen sometime soon using the Iterator interface, now that WordPress has finally left PHP 4 behind.
- jwarren 14y agoThere were a few others that I think were around in 2008, like Starkers, but my memory's a bit fuzzy so don't take that with any great authority. I definitely agree that a best-practise step-by-step theme construction guide in the Codex would be very useful. I still see many themes using things like query_posts() instead of creating a new WP_Query or a hooking into the pre_get_posts filter. As I mentioned below, Wordpress would ideally have its built-in functions trimmed dramatically, though this would really murder backwards compatibility. I don't really think it's Wordpress's fault that the Loop uses the alternative PHP control structure, but I agree that the Loop's Codex page is abominable. You may or may not be aware that the Codex is a wiki, and thus poor quality information can and will be added. I would like to see a loop using the Iterator class. However, there are quite a few complexities to that, as mentioned in this feature request [1]. They also point out that you can foreach and count on $wp_query->posts, so you can get to your information in a more obvious PHP-friendly way for now. [1]:http://core.trac.wordpress.org/ticket/20297 http://core.trac.wordpress.org/ticket/20297