aminabbasian
Member
Posted 8 months ago #
Hey Guys,
I am tryng to use a combination of loop.php and tag.php to list the post thumnbails for each tag.
The code in loop.php is http://pastebin.com/MgdJVGAE
This lists the posts by title but not the thumbnails.
I have tried this code http://pastebin.com/2yfE40WK
but it doesn't quite work.
Any ideas how I can resolve this?
aminabbasian
Member
Posted 8 months ago #
Please see the codes now in pastebin
aminabbasian
Member
Posted 8 months ago #
OK just an update on this.
I have started editing tag.php as follows:
$thumbnails = get_posts('numberposts=0&tag=Summer');
foreach ($thumbnails as $thumbnail) {
if ( has_post_thumbnail($thumbnail->ID)) {
echo '<a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">';
echo get_the_post_thumbnail($thumbnail->ID, 'gallery-220');
echo '</a>';
This code pulls all the tags under "Summer" but I want to be able to have this as an array of some sort. So that the page pulls the posts according to what the tags is.
get_posts('numberposts=0&tag=$get_the_tags'); or get_posts('numberposts=0&tag=$tag'); doesn't work.
I know I can echo the tag as set out here http://codex.wordpress.org/Function_Reference/get_the_tags but how do i uses this to be included within the codes above?
aminabbasian
Member
Posted 8 months ago #
ok figured it out!! :)
this is the final code
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
$thumbnails = query_posts("numberposts=0&tag=$tag->name");
foreach ($thumbnails as $thumbnail) {
if ( has_post_thumbnail($thumbnail->ID)) {
echo '<a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">';
echo get_the_post_thumbnail($thumbnail->ID, 'gallery-220');
echo '</a>';
}
}
}
}
aminabbasian
Member
Posted 8 months ago #
just an update on the code above.
how can i alter the code so that it pulls the tag ID or tag slug?
At the moment the tag name is pulled but if the tag name consists of two words the page search is blank.
any suggstions?