Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

rchak2000 on "Add categories as class in function"

$
0
0

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 all articles
Browse latest Browse all 8245

Trending Articles