Approaching recurring content in WordPress themes

The WordPress Twenty Twelve and Twenty Thirteen themes use identical ways to display entries inside the loop. Instead of calling the_title and the_content directly from among others index.php and single.php, they include a file for displaying the entry based on the post format using get_template_part combined with get_post_format.

Using this method, the themes handle the displaying of post entries via a single file (in this case, one file per post format), allowing the developer to easily change the outputted content for entries: instead of changing index.php, single.php, archive.php and all other files where a post entry is outputted, the developer can just change the appropriate template part file for the post format and alter the output on all pages where the template part is used.

So that’s one type of recurring content, and one way to handle it…

Continue reading

Stop using “page-” as a prefix for your themes page template files

Much has been written already about the WordPress template hierarchy. It’s an important part of WordPress, and understanding it is of vital importance to build proper themes. There’s a Codex entry devoted to it, Wptuts+ has created a cheat sheet for it and many, many articles have been written about its basics.

But, as is the case with many other WordPress topics, an at first sight promising list of results for a search query on the subject turns out to be a list of articles and tutorials that pretty much contain exactly what’s already in the Codex, but in a more readable format. What should be a list of interesting topics about the WordPress template hierarchy, its roots and why it is as it is, is actually the same article over and over again. Continue reading