problem with get_the_tags()
-
Hello, this get_the_tags() makes me crazy ??
I have the following php with loops:<div id="filter-blog-isotope" class="portfolio-filter"> <div id="count-projects"><!--<i class="font-icon-forward">--></i><span class="current-number">00</span><!--<span class="num-name"> / Related Information</span>--></div> <ul> <li><a href="#" class="has-items selected" data-filter="*">All</a></li> <?php //Define the loop based on arguments $loop = new WP_Query( $args ); //Display the contents while ( $loop->have_posts() ) : $loop->the_post(); ?> <li><a href="#" data-filter=".<?php $posttags = get_the_tags(); if ($posttags) { foreach($posttags as $tag) { echo $tag->slug; } } ?>"><?php $posttags = get_the_tags(); if ($posttags) { foreach($posttags as $tag) { echo $tag->slug; } } ?></a></li> <?php endwhile;?> </ul> </div> <div id="blog" class="wide"> <div id="blog-posts-container" class="normal-blog-pagination"> <?php //Define the loop based on arguments $loop = new WP_Query( $args ); //Display the contents while ( $loop->have_posts() ) : $loop->the_post(); $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?> <article class="item-blog <?php $posttags = get_the_tags(); if ($posttags) { foreach($posttags as $tag) { echo $tag->slug; } } ?>"> <div class="post-container"> <div class="post-creative post-image" style="background-image: url(<?php echo $url; ?>);"> <a class="post-link" title="<?php the_title(); ?>" target="_blank" href="<?php the_permalink(); ?>"> <div class="post-caption"> <div class="post-naming"> <h2 class="post-title"><?php the_title(); ?></h2> <span class="post-date"><?php the_content(); ?></span> </div> </div> </a> </div> </div> </article> <?php endwhile;?> </div> </div>
trying to display a sortable article list. Works well except that the classes for my articles are retrieved (as expected) from the tags in each post but only for the first 3 posts (maybe because there are for now 3 tags defined). I have to have for the isotope li data-filter form the tags (which seems to work perfecter the first) and classes for the articles in reference to them. What am I doing wrong here?
Thanks so much for help!
Garavani
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘problem with get_the_tags()’ is closed to new replies.