Add class name from CPT taxonomies name
-
Hi,
I add [display-posts wrapper=”ul” wrapper_class=”js-filter uk-child-width-1-4 uk-child-width-1-4m uk-text-center”] and I want to add custom classes to li elements. The classes shoud be a name form cpt taxonomies.
Now I add some code into core file to make it and it’s works but this metod is a bad..
In plugin below line 586 a add some code:$terms = get_the_terms(get_the_ID(), 'portfolio_category'); $class = []; foreach ($terms as $term) { $class[] = $term->slug; } $class[]='listing-item'; /** * Filter the post classes for the inner wrapper element of the current post. * * @since 2.2 * * @param array $class Post classes. * @param WP_Post $post Post object. * @param WP_Query $dps_listing WP_Query object for the posts listing. * @param array $original_atts Original attributes passed to the shortcode. */ $class = array_map('sanitize_html_class', apply_filters('display_posts_shortcode_post_class', $class, $post, $dps_listing, $original_atts)); $output = '<' . $inner_wrapper . ' class="' . implode(' ', $class) . '">' . $image . $title . $date . $author . $category_display_text . $excerpt . $content . '</' . $inner_wrapper . '>';
In front I have something like this:
<ul class="js-filter uk-child-width-1-4 uk-child-width-1-4m uk-text-center"><li class="identyfikacje-wizualne listing-item"><a......etc.
How I can do this by functions.php?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Add class name from CPT taxonomies name’ is closed to new replies.