wordpress - How to append tags as classes -


in loop going through posts how can append tags of post part of class of div?

              <?php       $page_name = $wp_query->post->post_name;       query_posts('category_name='. $page_name .'&posts_per_page=-1&orderby=date&order=desc');       ?>           <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>               <div class="galleryitem ">                     <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>                    <div class="titleplate">                       <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="permanent link <?php the_title_attribute(); ?>"> <?php the_title(); ?></a></h3>                   </div><!--end titleplate-->               </div><!--end galleryitem-->                    <?php endwhile; else: ?>                <p>sorry, no posts matched criteria.</p>            <?php endif; ?><?php wp_reset_query(); ?> 

you can use following codes print tags of post:

<?php $postid = get_the_id();  $tags = wp_get_post_tags($postid);  foreach ($tags $tag) { echo $tag->name . " "; //put space seperate every tag. } ?> 

these codes show tags of post, , can insert class attribute of exact div needed.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -