• Resolved rchak2000

    (@rchak2000)


    I’m having trouble adding a list of category name classes to the first LI. Ideally, i’d like the HTML output to be <li class=”category1 category2 category3″>. I’ve messed around with the get_the_category function but can’t seem to get it to work in this syntax. Anyone out there have any tips?

    $posts = get_posts("numberposts=" . $numberposts . "&orderby=" . $orderby . "&post_parent=" . $post_parent . "&post_type=" . $post_type . "&category=" . $category . "&tag=" . $tag);
    
               if($posts) {
                      foreach($posts as $post):
                              setup_postdata($post);
    
    				$metadata = get_post_custom( $post->ID );			
    
    		   	$return .= '<li>
                                                <a href="javascript:;">
                                                    <h3>' . get_the_title($post->ID) . '</h3>
                                                    <span>' . $metadata['feature_slideshow_description'][0] . '</span>
                                                </a>
                                            </li>';
    
    									endforeach;
                                    }
    
                            $return .= '</ul>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Add categories as class in function’ is closed to new replies.