x

Category Style Plugin for Wordpress 2

About CodeAndEffect_CategoryStyle
This plugin allows you to specify alternate HTML code for individual posts on listings pages for any chosen category.

To use this plugin, you will need to know something of PHP and HTML, a basic knowledge of Wordpress templates, and Wordpress’ Loop function.

How it works: Firstly, This plugin can be installed and activated without causing any changes to your Wordpress site.
You can even add the Bsic Template Install code, and the plugin will not affect your pages until you add a custom Loop include file.

When this plugin is called within the Loop, it checks each posts category ID and checks to see if an alternate style .php file
exists for it. If it does, the contents of that file is used to style the post, and not the default loop
in your CodeAndEffect Category Style plugin enabled template.

You can added the Template Embed code to any or all templates using the Loop, such as index.php and archive.php in your theme folder.

When you want to create your first custom Loop include file to style any post for a given category you simply need to:

1 Duplicate the code that appears within the Wordpress ‘Loop’ into another .php file.
2 Name the file with the category ID for the chosen category, for example ‘17.php
3 Place the new <catID>.php file into the ‘cande_categorystyle’ plugin folder, alongside the plugin itself
4 Finally, you need to add the plugin embed code into any template you wish to use it, for example
your index.php file in your chosen theme

Deleting any <catID>.php files will revert the style back to the default HTML for the template file.

Duplicating the Loop

The following is the most basic type of Embed for displaying title and post content:

<h2><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?></a> </h2>
<?php the_content(’Read the rest of this entry ยป’); ?>

* If you wished to use this code as the style for category number 17, you would save it into a file
* called ‘17.php’ into ‘cande_categorystyle’ plugin folder.

Basic Template file Install

* Within your chosen theme’s templates, locate the ‘Loop’, it will begin something like:
* <?php if (have_posts()) : ?>
* <?php while (have_posts()) : the_post(); ?>
*
* The second line begins the ‘Loop’, directly below this line, add the following basic code to call the plugin:

<?php
if (function_exists(”codeandeffect_categorystyle”)) {
if ($cande_includeTemplate = codeandeffect_categorystyle()) {
include($cande_includeTemplate);
continue;
}
}?>

* The above code first checks for the installed plugin, and secondly calls the plugin and assigns it’s response
* to a variable called ‘$cande_includeTemplate’, you can rename this as you see fit.
* The next line includes the file that the plugin response refers to, this is the include file that styles the
* category entry.
* the next line ‘continue;’ ensures that the ‘Loop’ passes to the next post, and so doesn’t repeat the post in
* the default style