Archived topic
How to add a prefix to category title and tag title in single post ?
6 replies · Started by Budi on August 23, 2021
Hi,
I want to add a prefix to category title and tag title in single post, not in category page.
This is an example of what I’d like to do:
Category name ==> What I’d like to show as the category title on my single post
Computer ==> Cheap Computer
Mouse ==> Cheap Mouse
Thanks in advance.
Hi Amin,
Any chance you can link us to the site in question?
You can use the private information field.
https://docs.generatepress.com/article/using-the-premium-support-forum/#private-information
Let me know :)
Hello,
Please check my private information.
Thanks.
Give this CSS a try:
.single-post .inside-article .entry-meta .cat-links a:before, .single-post .inside-article .entry-meta .tags-links a:before {
content: 'Sewa Apartemen ';
}
Let me know :)
Hello,
Can you give solution using php code ?
Some categories already had prefix.
I need to add prefix for certain categories which have no prefix.
Thanks.
Hi Amin,
Is there any particular reason for not adding the prefix to the actual name of the category?
And if the prefix has to be conditional (I assume that's the case if you're looking for PHP answers), can you tell us which categories you want the prefix to show and on what situations/condition do you want them to be added on (except for it being in single post page)?
Hello,
Several categories or tags already had prefix in their name.
I want the rule is like this:
$prefix="Sewa Apartemen";
$search=stripos($category_title,$prefix);
if ($search===FALSE) {
$category_title=$prefix.' '.$category_title;
}
Thanks.