In a single post – how to filter by category and add custom html?

Posted in: Newspaper
Post count: 22

Hi,

I need to add a custom HTML if a single post is in a specific category. Let’s say that category is “Business”

I need to put this html below the TITLE of the single post.

The custom HTML simple it’s just a <DIV>

SAMPLE:
<div>Sponsored</div>

How can I achieve this?

Requirement:
1. If a single post is belongs to “Business” category – add an the HTML below the Single Post Title.

NOTE: I already tried creating a custom function using the_title WP filter however – the problem is that it affects the menu items on my FOOTER area. My Footer Area is a cloud template and has a navigation menu block.

Can anyone help me how to achieve this?

thanks

Post count: 21065

Hello!

You can duplicate the cloud single post template, give it another name, and assign it to the business category’s posts. See https://forum.tagdiv.com/topic/different-logo-in-categorypage/ for more information. So, you can have a different template for your special posts. Edit that template and add the element called “raw HTML” and the code in that element.

Thank you!

Post count: 22

Hello Betina,

Can I assign a default template to all single posts that will be under a specific category? So every time I create a POST and put them under In Business category then it will automatically apply that template?

Post count: 21065

Hello!

There are some settings for a cloud template in the theme panel -> Categories -> https://prnt.sc/CT4XIGHkwdSl
We recommend using the cloud templates instead of default templates.

Thank you!

Viewing 4 posts - 1 through 4 (of 4 total)
The forum ‘Newspaper’ is closed to new topics and replies.