Create custom enhanced pages for categories and any taxonomy term and manage them as a custom post.
NEW Version 2.0.0 brings a great new feature: with some magic, if your theme displays category/term description, then it would be automatically enhanced.
Are you ready for more? You can customize the template by creating a content-ecp.php
file in your theme of choice.
Enhanced Category Pages allows you to create custom category and term pages by managing them using a special custom post type.
Premium code quality ensured by Codacy static analysis: grade A.
Features
content-ecp.php
file in your theme of choice<?php $GLOBALS['enhanced_category']->setup_ec_data(); ?>
(see install section)Future Features
content-ecp.php
in your theme folder to customize the display.Advanced usage options
Create content-ecp.php
in your theme folder to customize the display of the enhanced content. The custom post associated with category/term is set up, so all display functions for posts are usable.
<?php global $enhanced_category; // if not previously set up, then let setup_ec_data get the current query term/category if (empty($categoryId)) { $categoryId = null; } // get enhanced category post and set it up as global current post $enhanced_category->setup_ec_data($categoryId); ?> <!-- enchanced category page (ECP) content --> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <div class="post-thumbnail"> <?php the_post_thumbnail(); ?> </div> <div class="entry-content"> <?php the_content(); ?> </div><!-- .entry-content --> <?php edit_post_link( __( 'Edit'), '<footer class="entry-footer"><span class="edit-link">', '</span></footer><!-- .entry-footer -->' ); ?> </article><!-- #post-## -->
Display category/term page. Edit category/taxonomy template to show the content of the “Enhanced Category” (feel free to adjust to your needs):
//in category.php or taxonomy.php or any other place your theme displays the category/term content <?php global $enhanced_category; //get enhanced category post and set it up as global current post $enhanced_category->setup_ec_data(); ?> <!-- enhanced category content --> <?php the_post_thumbnail("medium"); ?> <?php get_template_part( 'content', 'page' ); ?> <!-- custom fields --> <?php get_post_custom(); ?> <?php // If comments are open or we have at least one comment, load up the comment template if ( comments_open() || get_comments_number() ) : comments_template(); endif; ?>
Display a list of categories:
//$categories is presumed to be an already fetched array of categories/terms foreach($categories as $category) { $GLOBALS['enhanced_category']->setup_ec_data($category->term_id); the_post_thumbnail('thumbnail'); }
We use the category_description
or get_the_archive_description
filters in order to replace the plain content with the enhanced one.
content-ecp.php
and content-page.php
partial templates are looked for (in that order) and the first found is loaded.Enhanced Category (safe name: enhancedcategory) custom post type is created and a post is generated automatically for each category/term.
Enhanced Category Post (ECP) is synchronized in both directions with it’s corresponding category i.e. category name – ECP title, category slug – ECP slug, category description – ECP excerpt.
Enhanced Category posts are deleted when the plugin is deleted using the WordPress plugin management page. Note: nothing is deleted when the plugin deactivated.
Yes, you can pass the category/term id to setup_ec_data
method like this ($categories
is presumed to be an already fetched array of categories/terms):
foreach($categories as $category) { $GLOBALS['enhanced_category']->setup_ec_data($category->term_id); the_post_thumbnail('thumbnail'); }
Enhanced Category Post (ECP) requires at least PHP 5.3 running on your server. Contact your hosting to update the PHP version.
category_description
or get_the_archive_description
filterscontent-ecp.php
theme partial template