hi guys,
I've wrote this little snippet, feel free to tear it to shreds but so far it does work:
Now, what this does (in plain english) is gets the tags associated with the current page, extracts the names from the array, then runs a WP_Query and implodes the tag names so essentially, it is finding posts within my project custom post type that have similar tags to this one...
Now then, the only tweak I want to make is to remove the current page from the $loop query, as its obviously the most similar post to itself...
Does that make any sense and can anyone help with this?
I've wrote this little snippet, feel free to tear it to shreds but so far it does work:
Code:
<?php
$tags = wp_get_post_tags($post->ID);
foreach ($tags as $tag) $tagNames[] = $tag->name;
$loop = new WP_Query( array( 'post_type' => 'project', 'posts_per_page' => 3, 'tag' => implode(",", $tagNames) ) );
?>
<ul id="recent-projects" class="clearfix">
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<li class="grid_4"><a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail($page->ID, 'thumbnail'); ?></a></li>
<?php endwhile; ?>
</ul>
Now, what this does (in plain english) is gets the tags associated with the current page, extracts the names from the array, then runs a WP_Query and implodes the tag names so essentially, it is finding posts within my project custom post type that have similar tags to this one...
Now then, the only tweak I want to make is to remove the current page from the $loop query, as its obviously the most similar post to itself...
Does that make any sense and can anyone help with this?
Last edited: