Home › Forums › CSS › There has got to be an easier way › Re: There has got to be an easier way
April 24, 2011 at 1:55 pm
#49452
shazdeh
Member
First of all, you don’t need all those !important rules. Check out this article: https://css-tricks.com/specifics-on-css-specificity/
There’s an easy way to create custom lists within WP: by using shortcodes. Here is the code from my own theme:
add_shortcode('news', 'theme_shortcode_list');
add_shortcode('anotherlist', 'theme_shortcode_list');
/* just like that. */
function theme_shortcode_list( $atts, $content = null, $code ) {
$content = str_replace('', '
', do_shortcode($content));
return $content;
}
What it does is that it adds a classname to the ul so you can hook to that classname in you CSS. What you do is wrap your ul’s around [check] or [news] or whatever shortcode name you define. Now in your CSS define styles for this lists:
ul.arrow li { whatever }
ul.news li { yeah! }