Add a badge to post title of specific catgory

Posted in: Newspaper
Post count: 19

Hello,

I would like to place an icon in the post title of every article from the category “plus”. That should be shown on every page, category-page and post-page. I’ve tried this in Custom CSS:

article.category-plus > header.entry-header > .entry-title:before {
content: url(‘wp-content/uploads/2020/05/C-Plus.png’);
display: block;
float: right;
margin-right: 10px;
width: 1em;
height: 1em;
}

and this in functions.php:


if (has_category( 'plus' ))
return;
echo '<style>
.entry-title:before {
content: url("https://testfeld051.magazin.de/wp-content/uploads/2020/05/C-Plus.png");
margin-right: 10px;
}
</style>';
}

Unfortunately, neither of them works. Does anyone have any idea how I can make it work?

Post count: 18283

Hello !

This will work easier if you will be using the Font Awesome plugin. Find our more in our guide here: https://forum.tagdiv.com/how-to-add-icons-in-menu/

Thank you !

Post count: 19

Hello,

Thank you for your answer. Unfortunately you did not understand my question correctly.

I do not want to insert icons in menus.

The task is this: I want to insert an image file in the size of a badge (20 x 20 px) in the title of each article in a specific category. This should be displayed on every page, on every category page and on every post page.

When using Custom CSS I cannot find any specified selector. For this I would need a hint please.

How the result should look like can be seen here:
https://bit.ly/2ZNqeL8

Post count: 35449

Hi tizian-ffm,

Our theme do not have an option for this, you can try a custom css, but this will work only inside the post/article, on modules/blocks will not work, for example -> https://i.imgur.com/T5gKFIf.png -> https://i.imgur.com/EJMH9iX.png
As a hint you can use in child them functions.php a code that identify the category id something like this

if (get_category('53')){
echo '<style>
.entry-title a::before {
content: "test";
margin-right: 10px;
}
</style>';
}

Hope this will help you!
Thank you!

Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.