How to create a category file for WordPress

This is an example that is based on a simple template that will allow us to integrate a personalized page for the categories of our website, of course, if it is working under WordPress.


Customize your website

Some time ago I made a theme change on my website; however, as expected, the change of thema means that we must revisit many of the configurations and functions that we had in our old theme, including the categories. Of course, this is not a straitjacket, nor is it something that is mandatory; In addition, many of the topics include a specific page for the categories.

However, in my specific case, the new theme did not have a category page (category.php), and the way in which the posts were shown did not like me. Starting because there was not even a title that indicated that it was a category page. And continuing because the full post was shown (something that is really unadvisable for a page of categories, since the idea is to make a link from the home or from all the pages to the categories, and that from them it shows not the article full). This serves to show on the same page about five post with their titles and a brief description of it (an excerpt), which makes the user experience more pleasant and, incidentally, helps us with the CTRL.

Anyway, following the thread of how to create a category file for WordPress, what we should do is the following:

We open a notebook (preferably) or our text editor and in it we insert this code:

<?php get_header(); ?>
<div id=»content»>
<h2><?php single_cat_title(‘Categoría: ‘,’TRUE’); ?></h2>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h3><a href=»<?php the_permalink() ?>» rel=»bookmark» title=»<?php _e(‘Link Permanente a’); ?><?php the_title(); ?>»><?php the_title(); ?></a></h3>
<?php the_excerpt(); ?>
<?php endwhile; ?>
<?php else : ?>

<h2>No Encontrado</h2>
<p>Lo siento, lo que estás buscando fue movido de ubicaci&oacute;n. </p>

<?php endif; ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

Then we save it with the name of: category.php and upload it to the folder where the files of our theme are. Ready, with this we will have already configured a simple template of categories for our web. Of course, it will only be necessary to make the additions and modifications that we consider pertinent. Enjoy it and any comments can leave it down, telling us your experience and how it went.

How to create a category file for WordPress
Take a look at the network to review how our website always suits us to se...

It happens that my agenda is filling with several links that, on the one h...

The domain market is something really big and, within the network, is an e...

When we hear the word cell phone safe we come to mind functions like calli...

Bibliography ►

phoneia.com (June 17, 2019). How to create a category file for WordPress. Bogotá: E-Cultura Group. Recovered from https://phoneia.com/en/technology/how-to-create-a-category-file-for-wordpress/