Guest User

Untitled

a guest
Aug 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. <ul class="flavorlist">
  2.  
  3. <?php
  4.  
  5. //FFUUUUUUUCKKKKK. I think the part below...
  6.  
  7. $temp = $wp_query;
  8. $args = array(
  9. 'category_name' => 'flavor',
  10. 'showposts' => 20,
  11. 'orderby' => 'title',
  12. 'order' => 'ASC',
  13. 'paged' => $paged
  14. );
  15. $flavorsPosts = new WP_Query($args);
  16. foreach ($flavorsPosts as $post) :
  17. setup_postdata($post);
  18. $count++;
  19. $test = $count-1;
  20. ?>
  21.  
  22. <li class="flavor <?php if (is_int($test/5)) echo 'first'; ?>">
  23. <?php
  24.  
  25. // ...is conflicting with the part below, perhaps.
  26.  
  27. //Get images attached to the post
  28. $args = array(
  29. 'post_type' => 'attachment',
  30. 'post_mime_type' => 'image',
  31. 'numberposts' => -1,
  32. 'order' => 'ASC',
  33. 'post_status' => null,
  34. 'post_parent' => $post->ID
  35. );
  36. $attachments = get_posts($args);
  37. if ($attachments) {
  38. foreach ($attachments as $attachment) {
  39. $img = wp_get_attachment_thumb_url( $attachment->ID );
  40. $imglink = wp_get_attachment_url( $attachment->ID );
  41. break;
  42. } ?>
  43. <a href="<?php echo $imglink; ?>" title="<?php the_title(); ?>"><img src="<?php echo $img; ?>" alt="yummy cupcake" /></a>
  44. <? } else { ?>
  45. <img class="default" src="<?php bloginfo('template_directory'); ?>/images/default.jpg" alt="Photo Coming Soon" width="60" height="60" />
  46. <?php } ?>
  47. <h3><?php the_title(); ?></h3>
  48. <p><?php the_excerpt(); ?></p>
  49. </li>
  50. <?php endforeach; ?>
  51. </ul>
Add Comment
Please, Sign In to add comment