- No categories
- All
How to check if there are posts with the same tag
I have this code but I can't get to delete the div with the class otrasObras <?php $test = ""; $posttags = get_the_tags(); if ($posttags) { foreach($posttags as $tag) { $test .= ',' . $tag->name; } } $test = substr($test, 1); query_posts('tag='.$test.'&showposts=-1'); if(have_posts()){ ?> <div class="otrasObras"> <h3>Contenido relacionado:</h3> <ul> <?php while (have_posts()) : the_post(); if($post->ID != $idPost): ?> <li> <a href="<?php the_permalink(); ?>" title="Ver la obra <?php the_title(); ?>"> <h4><?php the_title(); ?></h4> </a> </li> <?php endif; endwhile; wp_reset_query(); ?> </ul> </div> <?php } ?> I read a bit about this in here http://codex.wordpress.org/Function_Reference/WP_Query but they were using the object syntax. EDIT: .otrasObras is a module that I want to show only when it has content, and the content are other posts with the same tag, so if … [Read more...] about How to check if there are posts with the same tag
Learn More