COMPATIBLE WITH MOST OF THE WORDPRESS THEMES
TheCartPress 1.3.1 introduces universal theme compatibility making it compatible also with all WordPress themes.
TheCartPress has the ability to provide its core template files injected into standard WordPress templates in a seamless manner. In other words, users may now choose any WordPress theme for their site and then simply activate the TheCartPress plugin.
What this means is if you are on a TheCartPress page, TheCartPress will look for a specific template file in your theme and use that template.
TheCartPress 1.3.1 heralded a new era in TheCartPress development with a vastly improved approach to templating, its aim being to far more closely mirror the WordPress core templating loading approach.
TheCartPress template hierarchy
Template hierarchy for single product page (product details):
- single-$posttype.php
- single-tcp_saleable.php
- thecartpress.php TheCartPress code (tcp-single-product.php) is injected into the_content()
- page.php TheCartPress code (tcp-single-product.php) is injected into the_content()
- index.php TheCartPress code (tcp-single-product.php) is injected into the_content()
Template hierarchy for products archives:
- archive-$posttype.php
- archive-tcp_saleable.php
- thecartpress.php TheCartPress code (tcp-archive-product.php) is injected into the_content()
- page.php TheCartPress code (tcp-archive-product.php) is injected into the_content()
- index.php TheCartPress code (tcp-archive-product.php) is injected into the_content()
Template hierarchy for Custom Taxonomy archives (products categories, product tags, etc)
- taxonomy-$taxonomy-$term.php
- taxonomy-$taxonomy.php
- taxonomy-$posttype.php
- taxonomy-tcp_saleable.php
- thecartpress.php TheCartPress code (tcp-archive-product.php) is injected into the_content()
- taxonomy.php
- archive$posttype.php
- archive-tcp_saleable.php
- page.php TheCartPress code (tcp-archive-product.php) is injected into the_content()
- index.php TheCartPress code (tcp-archive-product.php) is injected into the_content()
In theme compatibility mode, you can overwrite the code injected by TheCartPress from your theme. Copy the templates you need to customize from thecartpress>theme-templates to your theme directory and customize them to suit your needs.
So, you could have 2 case, and TheCartPress automatically detects:
- If your theme has templates for TheCartPress, they will be used (eg: archive-tcp_product.php, single-tcp_product.php, etc.)
- If your theme does not special templates for TheCartPress, TheCartPress will look for a specific template file in your theme and use that template to load TheCartPress pages (page.php)
If your theme does not special templates for TheCartPress, now TheCartPress has the ability to provide its core template files injected into standard WordPress templates in a seamless manner. In other words, users may now choose any WordPress theme for their site and then simply activate the TheCartPress plugin. TheCartPress will automatically check to see if you have TheCartPress templates, if not it will fall back to using the new template files for theme compatibility (or from your theme directory) and select a template file from the parent in the same manner WP does in a template hierarchical fashion
E.G. If your theme hasn´t TheCartPress templates, TheCartPress will use page.php to generate the TheCartPress content. TheCartPress will look for a series of templates in a specific order much in the same manner WordPress does with it’s main templates ( to better understand template hierarchy read the WP codex page: http://codex.wordpress.org/Template_Hierarchy ) and will inject it in your thecartpress.php or page.php template.
To try and ensure that TheCartPress content fits in with a chosen theme as much as is possible, only a very basic set of styles are provided.
How is this useful?
Use a custom template file for all TheCartPress content
TheCartPress is used while not having to modify the standard WordPress file e.g. page.php
So if we want to remove the sidebar for TheCartPress pages but not for all WP ‘pages’ or call a specific TheCartPress sidebar get_sidebar(‘TheCartPress’), we could take a copy of page.php and rename it to ‘thecartpress.php.’
Overloading Template Compatibility theme files
Template compatibility also runs a check to see your theme has TheCartPress theme compatibility templates. To overwrite the injected code you can copy the templates injected into your theme.
Therefore, you can modify any TheCartPress theme compatibility template by copying it over from:
/thecartpresss/themes-templates/
To: /my-theme/
Child Themes
As mentioned earlier, TheCartPress will search templates for TheCartPress files/folders. This means that the principle of creating child themes still holds true and is to be a strongly recommended procedure to follow as always.
For information on creating child themes see: http://codex.wordpress.org/Child_Themes
This has been a basic guide to familiarise you with the new template files and how you can make them work for you in your chosen theme and more advanced options exist.
As of TheCartPress 1.8 we introduce an enhanced template hierarchy, this new addition allows the developer to specify unique templates for TheCartPress screens.