We are now rapidly approaching 100 posts on the blog. What this meant for the users is that it has become increasing hard to navigate the website and the posts.
Secondly what this meant to the server side is that the load time had increased.
Changes to the category page
We felt that the most significant improvement that we can bring to the blog to address the two issues above was to make the category page list the posts, without the full post and without the excerpt.
This brings two advantages:
- The users can now easily find all posts inside every category. Previously they had to go through every post’s content. This was fine when we had a few posts but going through pages of content to find post titles was an unpleasant experience.
- The other advantage is that providing only the post titles instead of the content means that the server has much less work to do.
How we changed the category page to only list posts?
We are a knowledge blog and as tradition let us explain to you what we did in code. This blog is run on WordPress if you have not realised it yet and a variation of the TwentyTwenty theme: Free AMP WordPress Theme with 2 Sidebars
We introduced a category.php file inside the main folder next to functions.php. You can introduce other files with different levels of control to categories, see more here: https://developer.wordpress.org/themes/basics/template-hierarchy/
A simple category template
We used the code from https://www.wpbeginner.com/wp-themes/how-to-create-category-templates-in-wordpress/ which provides a really good explanation on categories and made it simpler as follows:
<?php
/**
* A Simple Category Template adapted from https://www.wpbeginner.com/wp-themes/how-to-create-category-templates-in-wordpress/
*/
get_header(); ?>
<section id="primary" class="site-content">
<div id="content" role="main">
<?php
// Check if there are any posts to display
if ( have_posts() ) : ?>
<header class="entry-header has-text-align-center header-footer-group">
<h1><?php single_cat_title( '', true ); ?></h1>
</header>
<div class="section-inner has-text-align-left ">
<ul class="wp-block-latest-posts__list wp-block-latest-posts">
<?php
$count = 1;
// The Loop
while ( have_posts() ) : the_post(); ?>
<li>
<h4> <a class="wp-block-latest-posts__post-title"
href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<?php echo $count."."; ?> <?php the_title(); ?> <?php $count = $count + 1; //the_time('d/m/Y') ?> </a> </h4>
</li>
<?php endwhile;
else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
</ul>
</div>
</div>
</section>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
The main changes are the html elements and the style to adapt it to TwentyTwenty. We are debating at the moment on whether to display time next to the posts, hence the comment in the code.
This code basically just lists all posts under every category in the while loop and then create an HTML list <li> with a link to every post.
Introducing new Categories: Gaming and Management
We have also introduced two new categories which are Gaming and Management. Gaming has always been a big part of the blog and now we are introducing management which we plan to grow in the blog. The Management part will still be relevant to Technology.
Finally, thank you for reading the blog for the past 1+ year. We hope to continue for many more year and to provide you with many more educational articles.
If you want to read further, check our new article and category on management: What is the best project management professional certificate for managers in Technology