I’ve been developing and managing WordPress sites for a few years, but one area I had not yet explored was WordPress plugin development. I wanted a way to show a post’s feature category on this blog when the post is listed on the front page. I couldn’t find a WordPress plugin that offered this functionality, so I decided it was a good time to get into plugin development.
The Category Title Prefix is very simple. It adds a filter to the_title that checks first to see if we are on the front page and then to see if the post type is ‘post.’ If both of these things are true, it uses wp_get_post_categories() to get an array of categories associated with the post and then uses that information to add the category name to the front of the title.
If you want to try the plugin, it can be installed two different ways:
1. Go to Plugins > Add New in the admin panel and search “category title prefix.” Click “Install plugin.” Then all you need to do is activate it.
2. Visit the WordPress Plugin Directory and download the plugin from there. Then you can upload the plugin files to your wp-contents/plugin folder. Visit the Plugins > Installed Plugins page in your admin panel and you should see it there. Just activate it to start using it.
3. Copy the PHP code from the snippet above and paste it into a file called rw-ctp-category-title-prefix.php. Save the file and upload it to you wp-contents/plugins directory. Visit the Plugins > Installed Plugins page in your admin panel and you should see it there. Activate it to start using it.