How I fixed Wordpress category page title: Category <span>...</span>
One one of my Wordpress sites, the title of category pages was literally
category_title_example.txt
Category <span>My category</span>
Searching through the theme source code didn’t yield a solution quickly, so I added this custom JS using a plugin:
fix_category_title.js
jQuery(document).ready(function( $ ){
if(jQuery("h1.page-title").text().includes("Category: <span>")) {
var input = jQuery("h1.page-title").text();
var output = /<span>(.*)<\/span>/g.exec(input)[1];
jQuery("h1.page-title").text(output);
}
});
This will just replace the title by the content of the span tag. You might need to adjust the CSS classes for your theme.
Check out similar posts by category:
Javascript, Wordpress
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow