Simple WordPress Plugin (Needs to be Sanitised and Escaped)
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitattributes
.gitignore
README.md
cat-admin.php
category_plugin.php

README.md

#Category Archive SEO Plugin for WordPress

This plugin was intially developed for SEO work with WordPress themes. It is considered at this moment in time that repetitive content on WordPress archive pages might be bad for overall Serach Engine Rank. Some themes already have support for category descriptions. However many do not and there is also a case for having the naturally integrated desciptions work as the meta description tag.

The plugin requires some code adding to the functions.php file and the themes archive page. I have left it like this because it was the first plugin I had developed.

##Code for archive file (usually archive.php)

 <?php if ( is_category() ) { ?>
                  
                        <?php
                      
                       
                  category_desc(); 
                        
                        
                        ?>
                <?php } elseif (is_tag()) { ?>
                   <?php   
                   
                   
                  category_desc();
}
?>

##Code for functions file (usually functions.php)

<?php 
function category_desc(){
   
     global $wpdb;
 $content = '';
$prefix = $wpdb->prefix;
$results = $wpdb->get_results( 'SELECT * FROM ' . $prefix . 'intro');
$headline = '';$tag = '';$description ='';
foreach($results as $item){
    $content = stripslashes($item->description);
    $number =  $item->index;
    $head = $item->headline;
    $tag = $item->tagline;
    $time = strtotime($item->timecol);
    $new = date('Y-d-m',$time);
   if(is_category($item->category)){
        $headline = '<div><h1 style="margin-bottom:10px;">' . $head . '</h1>';
        $tagline = "<div class='tagline'>" . $tag . '</div>';
        $description = "<div style='padding:0%;margin:0%;'>" . $content . "</div></div>";
    }
   if(is_tag($item->category)){
        $headline = '<div><h1 style="margin-bottom:10px;">' . $head . '</h1>';
        $tagline = "<div class='tagline'>" . $tag . '</div>';
        $description = "<div style='padding:0%;margin:0%;'>" . $content . "</div></div>";
   } 
}
$content= $headline . $tagline . $description;
print $content;
}
?>

##NOTES

I would advise to only use the plugin in a development environment on your localhost. It still needs on one end to have the content sanitized and on the other escaped. More in this article in my personal blog: Plugin Guidelines