How should I best target dynamically served content?

I am editing the ‘Bizz’ portfolio WordPress theme(http://www.wpexplorer.com/bizz-wordpress-theme). It includes custom post types for managing portfolio examples, the highlights on the homepage, etc.

I want to style the background color displayed behind each ‘highlights’ heading with a different color, but since they’re served dynamically, I’m not sure how I should target each h2.

Read More

Would it be best to attach a unique class to each of the three headings through the php, or try to target them through CSS selectors? And how would I best do that?

My major concern in using CSS selectors would be backward compatibility, I dont know that I want to bulk up the page with extra bootstraps.

How should I go about it? Thanks!

Related posts

Leave a Reply

1 comment

  1. I think it depends on whether you want it to be unique for each of the four “highlighted” project columns on the homepage, or whether you want each “highlighted project” to be different.

    Does that make sense?

    E.g. if you just want each of the four project “columns” on the homepage to look different then I’d use CSS to achieve this : nth-of-type perhaps.

    But if you wanted Project A (when highlighted on the homepage) to have a unique background colour regardless of what column it appears in, then Id use PHP to add the post->ID as a class in addition to portfolio-item and then use CSS to style that.