A few of my recent projects involved creating themes for websites that are divided into sections. In some websites a section can be as simple as a native WordPress category. In my recent projects sections were more challenging then that:
- Each section could have it’s own pages/
- Each section could have it’s own categories, sub-categories and, of-course, posts.
- Each section required a different sidebar / widget-areas.
- Though some sections has no sidebars and some sections had shared widget-areas.
- Sections occupied the top-navigation of each website – and sometimes the designs required an identifier of “current-section” for pages, categories and posts.
- One website design included an image for each section.
Over the course of a few projects I built and refined a small extension to the Thematic Theme Framework (which is the foundation for all of my WordPress themes) and called it Thections.
You can currently see sections at work at iamronen.com and feminitate.org.
What does Thections do?
- It enables a theme designer to easily add a section using an array of parameters.
- Content can be associated with sections by setting a root-page and root-category.
- It generates an access menu based on the added sections.
- It can automatically register numerous separate sidebars (widget areas) for each section.
- It can automatically register one navmenu location for each section.
- It can be used to hook alternative category loops for each section.
- It has filters that can be used for customizing the section navigation menu.
- It has actions that can be used for enhancing the widget-areas (eg: registering and adding shared widget areas).
- It has section-sensitive filters for easily modifying post-footers and post-headers.
What doesn’t Thections do?
- It doesn’t have an admin user interface – adding sections is very simply but requires intervention by a theme designer.
- It doesn’t modify other template files or CSS to accomodate containers with/without sidebars.
- It isn’t professional code, it hasn’t been thoroughly tested or optimized (but it is working in live websites). It would be great if someone from the thematic community could work some poetic-code magic on it to make it better.
How to use it?
- You need to have the Thematic Theme Framework installed.
- You need to create a child-theme.
- Download thections.zip, extract and add the file ‘thections.php’ to your child theme.
- Add to your child theme’s ‘functions.php’ file the following code:
require_once('thections.php');
- Add sections by calling
thection_add_section(array(parameters)); for each section.
- Refer to the brief documentation in ‘thections.php’ on the required parameters.
- Refer to the code itself (it’s fairly straightforward) for available filters & actions.
I’d love to hear if it was helpful to you or any feedback you have on how to make it better.
Updates
July 10, 2010: Version 1.02
- Added version numbering – to keep track of things
- Added filter ‘thection_test_taxonomy_archive’ for testing current section in custom taxonomies.
- Added filter ‘thection_test_taxonomy_single’ for testing current section in custom post types.
- Added option ‘show_inmenu’ for declaring sections that are not presented in the main navigation menu (but still have, for example, their own sidebar).
- Added interface function ‘thection_get_section_link()’ which returns an href-link for a section.
- Fixed return error in post-meta data main filter function.
- Fixed bug in page-hierarchy testing.
Thections: Creating WordPress Websites with Sections
A few of my recent projects involved creating themes for websites that are divided into sections. In some websites a section can be as simple as a native WordPress category. In my recent projects sections were more challenging then that:
Over the course of a few projects I built and refined a small extension to the Thematic Theme Framework (which is the foundation for all of my WordPress themes) and called it Thections.
You can currently see sections at work at iamronen.com and feminitate.org.
What does Thections do?
What doesn’t Thections do?
How to use it?
require_once('thections.php');thection_add_section(array(parameters));for each section.I’d love to hear if it was helpful to you or any feedback you have on how to make it better.
Updates
July 10, 2010: Version 1.02