Hi @vanw,
Right now it is only possible to do this with post tags, using the tags_as_class shortcode parameter. It is not possible to do what you want with the shortcode only, but you could do it using a custom template.
Thread Starter
VanW
(@vanw)
Hello zymeth25,
Thank you for your reply,
I’ve already started working on my template, however still can’t find the right solution.
This is what I have, but doesn’t work.(inside the loop)
if ( in_category( 'webinar' )) {
$lcp_display_output .= '<li id="webinar" class="webinar">';
} elseif ( in_category( 'events' ) {
$lcp_display_output .= '<li id="event" class="event">';
} else {
$lcp_display_output .= '<li id="other" class="other">';
}
endif;
can you please suggest solution?
with regards
Van
First of all, using categories as id is a very bad idea because many posts can have same category. Only one HTML element should have a given id, but same class can be assigned to many different elements. So I suggest you use classes only for this purpose.
Now, this code should do just what you want (inside The Loop):
$categories = get_the_category();
$lcp_display_output .= '<li class="' . $categories[0]->slug . '">';
Thread Starter
VanW
(@vanw)
zymeth25
Thank you for your help. The IDs was leftover from previous testing.
Your answer helped.
Thank you for your time
with regards
Van