Category Editor and Custom Taxonomy

Using Category Editor Pro With Custom Taxonomies

Category Editor does not support WordPress custom taxonomies out of the box. The plugin  is aimed at WordPress categories and tags and also Woo-commerce product category and tags. Admittedly, the Woocommerce categories and tags are custom taxonomies but generally Category Editor Pro Does not supportr custom taxonomies.

Currently,  more and more WordPress users are taking advantage of custom taxonomies. More themes and plugins are using custom taxonomies. Web site owners want to present a standard look across their web site. So it is pretty certain that many want to add a second description box below their custom taxonomy listings in much the same way they can with WordPress and Woocommerce archives.

Custom WordPress taxonomies can be supported

It is possible to display the content of a custom taxonomy archive with a small addition to the code of Category Editor Pro. This will display the content to help you with SEO and user experience. This code will only work if the custom taxonomy makes use of the end_loop hook,

Will I add this function to a future version of Content Editor Pro V5 or v4? It’s unlikely. The reason is that there are so many ways that themes and plugins build their custom taxonomies. Not all are done the recommended way. Not all use the standard WordPress post loop on those custom archive pages.

The result is I will have to dedicate a lot more time to support and trying to get the plugin to work on peoples sites. This will inevitably mean a substantial price rise for the plugin to cover this extra time.

I don’t believe that the vast majority of the people who use the Category Editor Pro plugin needs this feature. ‘I don’t think they would be prepared to pay the extra for the plugin. So, it is not likely to make the normal plugin.

But it is easy to add yourself. If you don’t feel confident to do yourself then let me know and I’ll get it working for your custom taxonomies for a price.

Category Editor Pro V5 and Custom Taxonomies

Starting with Category Editor Pro. For this to work and display the second description below the listing the taxonomy must use the standard WordPress loop. This is because the bottom description uses the end_loop hook to take action on and display.

If your custom taxonomy archive uses another custom loop then you will need to use Category Editor Pro V4 because V5 will have nothing to hook onto.

The code to display bottom description on custom taxonomies:

add this code to the main plugin php file:

if ( is_tax()) {
global $wp_query;
$q_obj = $wp_query->get_queried_object();
$cat_id1 = $q_obj->term_id;
$tag_data = get_option(MY_TAGS);
if (isset($tag_data[$cat_id1])){
if(get_query_var('paged') < 2){
echo ' <div class="term-description">';
echo do_shortcode(wpautop($tag_data[$cat_id1]['bottomdescription1']));
echo '</div> ';
}
}

In Category Editor Pro V5 you add this code at:

find starting at about line 500

if ( is_tag() && in_the_loop () ) {
$term_id = get_query_var('tag_id');
$tag_data = get_option(MY_TAGS);
if (isset($tag_data[$term_id])) {
if(get_query_var('paged') < 2){
echo '<div class="term-description">';
echo do_shortcode(wpautop($tag_data[$term_id]['bottomdescription1']));
echo '</div>';
}
}
}

}

add_action( 'loop_end' , 'wordcatins', 1000 );
remove_action('wp_head', 'wordcatins');

 

Paste the code into here BEFORE the last curly closing bracket displayed before add_action.

This will then check if the archive page is a custom taxonomy. If it is then it will look the the end_loop hook and add the bottom description area automatically.

 

Using Category Editor Pro V4 With Custom Taxonomies

If you are using V4 and adding the code for the bottom description manually then you do pretty much the same thing.  But you don’t need to do anything to the plugin. You need to change the code you use to insert the bottom description.

Currently the code on the plugin page tells you to insert this is the place you want your bottom description to appear in;

<div class="taxonomy-description">
<?php
if ( is_category() ) {
		if ( $paged < 2 ){	
 $current_cat = get_query_var('cat');

$cat_data = get_option(MY_CATEGORY_FIELDS);
if (isset($cat_data[$current_cat])) {
 echo do_shortcode(wpautop($cat_data[$current_cat]['bottomdescription']));
}
		}
}
if ( is_tag() ) {
		if ( $paged < 2 ){	
$term_id = get_query_var('tag_id');
$tag_data = get_option(MY_TAGS);
if (isset($tag_data[$term_id])) {
 echo do_shortcode(wpautop($tag_data[$term_id]['bottomdescription1']));
}
}
}
?>
</div>

You need to replace this code in your template file with this one:

<div class="taxonomy-description">
<?php
if ( is_category() ) {
if ( $paged < 2 ){
$current_cat = get_query_var('cat');

$cat_data = get_option(MY_CATEGORY_FIELDS);
if (isset($cat_data[$current_cat])) {
echo do_shortcode(wpautop($cat_data[$current_cat]['bottomdescription']));
}
}
}
if ( is_tag() ) {
if ( $paged < 2 ){
$term_id = get_query_var('tag_id');
$tag_data = get_option(MY_TAGS);
if (isset($tag_data[$term_id])) {
echo do_shortcode(wpautop($tag_data[$term_id]['bottomdescription1']));
}
}
}

if ( is_tax()) {

global $wp_query;
$q_obj = $wp_query->get_queried_object();
$cat_id1 = $q_obj->term_id;
$tag_data = get_option(MY_TAGS);
if (isset($tag_data[$cat_id1])){
if(get_query_var('paged') < 2){
echo ' <div class="term-description">';
echo do_shortcode(wpautop($tag_data[$cat_id1]['bottomdescription1']));
echo '</div> ';
}
}
}

?>
</div>

Your custom taxonomy archive pages should now be ready for you to add those valuable long-tail keywords and to develop the archive page into a fully fledged content hub page so loved by both visitors and search engines.

Any related questions please leave a comment below.

Spread the love
Posted in Plugin Support and tagged .

Blog postings from the developer of Y Praise Digital. some thoughts and wonderings of a web developer of over 25 years experience.

Leave a Reply

Your email address will not be published. Required fields are marked *