design wordpress category page

How To Use Category Editor With Non-Standard WordPress Themes

By default the Category Editor plugin should work out of the box provided the theme you are using is developed to WordPress standards. The bottom description area is automatically inserted below the listings using the end_loop hook.

However there will be times when the automatic placement of a text area below the listings does not occur, or happens in th worng place. If a theme does not use the standard WordPress loop to display the listings then there is no end_loop hook to take action on. This means that the bottom description or text area will not display on the front-end of the archive page.

Manually placeing bottom text area below WordPress archive listings loop

Also, many themes will use the end_loop hook to display the pagination of archive pages. If this happens in most situations the bottom description area will appear below the pagination menu of listings. This is because Categroy Editor is set with a very low priority of 1000 to encourage it to be displayed after all other actions on the end_loop hook.

Sometimes through themes will have the pagination hard coded into the theme after the end_loop hook. In that situation the bottom text area will appear between the end of the listings and the top of the pagination navigation.  This may not be what you want and you may prefer the bottom text area to appear after the pagination. This may be better if you have a long text area that you don’t want people to scroll through to get to the next page of listings in the archives.

In these situation the way forward is to use Categroy Editor 4 and add the code manually to where you want the bottom text area to appear. This is best done in a child theme and is not that difficult to do if you have just a basic knowledge of a WordPress template.

You just need to make a copy of the template for your archive. Then copy and paste the following code where you want the bottom description to appear.

Adding extra description area below listings on archive pages

WordPress

Add this following close to your archive or category PHP file in your theme folder – I would recommend you set up a child theme so it does not get overwritten when you update your theme. You need to place the code somewhere after the closing loop and it will very much depend on your theme for the exact place. If you have a problem then please contact me using the form. I will try and help but I will need admin access to your WordPress site and preferably FTP access. This code will only show the bottom content area on the first page of listings which is the best way for search engine optimisation.

  <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>

 WooCommerce

Use this code to add the bottom content area to WooCommerce archive pages – look for the archive-product PHP file and again add this to the bottom of the loop after it has been closed. This code will show the bottom content area on the first page of the product listings page.

<div class="term-description">

<?php
if ( is_product_category() OR is_product_tag()) {
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 do_shortcode(wpautop($tag_data[$cat_id1]['bottomdescription1']));
}
}
}

?>
</div>

This will ten display the bottom description area on both WordPress and Woocommerce archive pages of themes that do not use the default loop and end_loop hook.

 

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 *