Conditional Post Title Coloring Dependant on Category?

Posted in: Newspaper
Post count: 102

How can I have conditional post title coloring? For example if a post is in category1 then the title text sitewide should be red, category2 would be green, etc.

With my old theme I used to be able to add the custom CSS “.category-stingers .entry-title a { color: green; }”. I’ve used the inspect element tool on my browser but just can’t figure out how to accomplish this.

Post count: 102

Or have the ability to show the colored category box w/name in the thumbnail for only certain categories?

With my current theme (hopefully soon to be old theme), certain categories have color coded titles. I do this as a way to quickly look at a post or list of posts and see which ones are in certain categories.

Post count: 6600

Hi,

Unfortunately adding conditional for posts title isn’t easy and you need custom work for that or a plugin as the theme doesn’t have a feature like that but you can add the category tag like this: https://forum.tagdiv.com/topic/block-4-meta-help/#post-27896
Try the example from the URL I have sent you and see if this works for you.
Hope this helps!

Thanks

Post count: 102

Thanks! Couple questions…

1. Can I have it just show certain categories? I don’t want all shown, I’d like it to only show one of three different possible categories. And if it’s none of them, then to not show at all. Would that be possible?

2. Can this be done for all modules the same way? How about the main slider or carousel? Is it possible to implement this on those?

Thanks again!

Post count: 6600

Hi,

1. You could try to exclude a certain category by adding this $category->cat_ID !=1 to the categories condition, should look something like this: http://screencast.com/t/QzdNM5Jb8
This will exclude the “Uncategorized” category label. You should try to add there the ones you don’t want using the ID’s of them.

2. Yes, you can do it the same way for modules but you will need a different approach for sliders and you will need custom work for this. We suggest to hire someone to helps you with this if you don’t know how to do it as we cannot offer custom work at this time.

Thanks

Post count: 102

Thanks, that does help!

However, the categories that I want to show are sub-categories, so the parent category is still showing even though I added it to the excluded list. Any way around that?

I can work around this for now, but long-term I’d like to show sub-categories without the parent category showing.

Also, how can I get this working with module 6? I tried copying the last half of the code from module 3, but that didn’t do anything.

Post count: 102

Nevermind that last part. Looked at it again and realized I missed defining the function (<?php echo $this->get_category(); ?>)

Post count: 6600

Hi,

Please make a back-up of your current td_module_6.php file then replace it’s content with this code: http://pastebin.com/eBMf32NB and check if it works. Should return only the subcategories tags.
Please let me know!

Thanks

Post count: 102

Yes, that works, but it then shows all of the subcategories like it was showing all of the categories before. So I would have to do the exclude thing again. I just reverted back to the version that I modified with all of the categories that I needed excluded (which was all but three). Ideally, it’d be nice if instead of excluding I could just include as I only need three included, but about two dozen excluded. Plus, I will need remember this when I create new categories in the future.

So, I’m fine with the way it is currently, but long term, I’d be nice if my suggestion could be considered in a future update.

Post count: 6600

Hi,

I understand, unfortunately this is how this feature was build initially and changing it is not on our todo list but we will consider your suggestion if we decide to modify this.
You can try to add the categories like this $category->cat_ID = 1 to include them.

Sorry for the inconvenience and thanks for the message!

Post count: 102

Hello again, I’ve recently upgraded to version 6 and am trying to implement this again but these instructions no longer work. Please advise as to how I can accomplish this with the latest version of this theme? Thanks!

Post count: 22421

Hello,

The function Lucian has provided for version 4 will not work anymore on the current version because now there already is a category tag on modules function. The tags can be activated here: http://screencast.com/t/nwBCcCgfj3tY so you can select on which module you want the category to be displayed: http://screencast.com/t/TUjZbaR1
If you want to assign color to them, you can replicate this from the post category tag color: http://screencast.com/t/tJTHqIeBRSBhttp://screencast.com/t/gct7mUgA6HFy

I hope this helps
Thanks.

Post count: 102

Thanks, but I have two more questions now. First, how can I only show certain categories in the block? All my posts have multiple categories assigned to them, but I’d only like certain tags to show in that block.

Secondly, are you sure that’s the right screenshot for coloring them? I don’t see how to do that there.

Post count: 7909

Hi,

You have an option to set primary category for each of your posts, if you have multiple actegories – http://screencast.com/t/yUqDh7m2pffT If you don’t set the primary category, it will display on modules the first category in alphabetical order.
The color of the category on modules/blocks can be changed using custom css in Theme Panel > Custom Css – http://screencast.com/t/VOkPxAWbnJe

.td_module_wrap .td-post-category {
background-color: #BB391B;
}

It will not take the color that you set in Theme Panel for each category, this will be applied only for post pages – http://screencast.com/t/NTdZL30M7bRS If you need this you need custom modifications to change the get_category function used on modules – http://screencast.com/t/jPN396cW3 like Bogdan suggested above take at reference the function used for categories on post pages – http://screencast.com/t/gct7mUgA6HFy
I suggest to get someone to help you, as the time doesn’t allow us to provide custom work, sorry!

Thanks!

Post count: 102

Thanks, but the primary category would be one of three possible choices. How can I configure it in such a way that if one of those three categories are assigned, it would choose that as the primary?

Post count: 7909

Hi,

Yes, you set to the primary category spot the one you want to display on the module.

Thanks!

Post count: 102

The problem is that I have about 4000 posts, going through every single one of them to set the primary category is not acceptable. There should be a way where I can define multiple categories that would be unique to the posts and have one of those be considered the primary category. Would you like to have to manually go through every single post to correct this?

Post count: 7909

Hi,

I said above that the primary category is displayed in alphabetical order, if you don’t set it from Post Settings, so you will have a category on modules even if you don’t set it. I have checked your site and you don’t have category tag on modules enabled, please check Theme Panel > Block Settings – http://screencast.com/t/vHvXe8Fc
Please check the documentation – https://forum.tagdiv.com/category-tag-on-modulesblocks/

Thanks!

Post count: 102

Correct, I don’t have them enabled because they are useless to me as they are now. Please read carefully…

The problem is that I have about 4000 posts, going through every single one of them to set the primary category is not acceptable. There should be a way where I can define multiple categories that would be unique to the posts and have one of those be considered the primary category.

The primary category would be one of three possible choices. How can I configure it in such a way that if one of those three categories are assigned, it would choose that as the primary and shown on the category tag?

Post count: 7909

Hi,

In old version of the theme it wasn’t any option to display post category on modules and you had to modify this in the code, this was a temporary solution and even this was not complete as all the subcategories were displayed.
We have added the primary category spot in version 6 like we have promised, but this is not a general option, you can set it only for each post. Unfortunately I cannot provide you a solution for this and I don’t think it is possible(or it is really not an easy task) to achieve this even if you are hiring a developer to do this for you. How to figured out what categories you want to be set as primary for all of your posts if you don’t set it for each post?
I will add this on our requests list but I’m sure it is not an easy task, but I cannot promise you anything. If we will find a solution it will be implemented.

Thanks!

Post count: 102

This is unfortunate that the newest version doesn’t work as well as the old version in this instance. If you look through the previous conversation I’ve had here, I was able to configure which categories I wanted displayed.

See, almost all of the posts on my site belong to one of three “main” categories. And displaying one of those three categories tags gave a quick way for visitors to know a major item of note for those posts.

I’m no programmer, but I find it hard to believe that there isn’t any way at all to accomplish this again. Or maybe a way to prioritize which tag is shown, something other than alphabetical?

If there is nothing that can be done, then there is nothing that can be done. I just find it hard to believe this isn’t at all possible.

Post count: 22421

Hello,

The fact is that the code was changed in such a way that it will be very hard to make a customization like that. A professional developer will be able to do it, but it will involve changing quite a bit of the code and functionality. It will require substantial coding knowledge. So if you really need this customization done, you can hire a freelancer to do it from sites like studio.envato.com or other websites that offer freelance services.
Bottom line: it is possible, but we cannot help you in this matter as it falls beyond what the theme support can offer you.

Thank you for your understanding.

Post count: 102

Can you please clarify how to assign color to these tags? I’m trying to see if I can make it work as it is and the next step is to figure out the coloring and the instructions you provided earlier were a little vague and I can’t figure out where to make the changes at.

Post count: 22421

Hello,

The category tags on modules/blocks cannot be colored from the theme panel. This was a design choice to avoid too many colors on the front page. It can be done with css as Alin suggested above:
http://screencast.com/t/VOkPxAWbnJe
.td_module_wrap .td-post-category {
background-color: #BB391B;
}

Alternatively you can select block color to differentiate a specific category by color as our home page is set up: http://demo.tagdiv.com/newspaper/ same block type, different category, different color. You can do this from block settings in visual composer. You can also use the ajax filter to select sub-categories to display

I hope this helps
Thank you.

Post count: 102

Yes, it looks like using something like

.td_module_wrap .td-post-category {
background-color: #BB391B;
}

would do it, but I can’t figure out how to define what color for what category? Like I said, there are three categories, and each one should have it’s own color (red, green and orange). How would I define the color for each category?

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