add css class dynamicly to posts in modules..

Posted in: Newsmag
Post count: 2

I’m trying to find a way to add a class to posts in a module.
Example:
On the front page we have a listing of x posts from a given category.
Two of these is sponsored content.
I am using Advanced Custom Fields to define the post as “sponsored” in the admin-area, and therefore a meta- value is assigned to the post (e.g. “is_sponsored”).
How can I add a “sponsored” class to each post in any list without going the long way and changing the code everywhere in the theme?.

Post count: 23312

Hello MrLeif,

Unfortunately, the theme does not allow you to add a custom class to each post you want, sorry! You should find another alternative to target them using the post ID, sorry!

Thanks for the message!

Post count: 2

Thanks for the reply. But can I “plug in” to this code?

$this->get_module_classes();

If I could use a hook to this, maybe i could have a function that picked up the ID, do my own processing (check for the meta key) and return the class I want to be added?

Post count: 23312

Hello MrLeif,

Unfortunately, as you want to achieve involves doing such a custom work and we cannot provide something like this at the moment, sorry! If you want to make some additional customizations and if you are not aware of the steps which are needed to take in this case, please consider hiring a freelancer/developer to help you!

Thanks for your understanding!

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