wordpress resimli haber


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <!-- GALLERY VIEW-->
  2. <div class="gallery">
  3.  
  4. <?php
  5. $mainGallery = new WP_Query();
  6. $mainGallery->query('post_type=post&showposts=5');
  7. $i=1;
  8. ?>
  9. <?php while ($mainGallery->have_posts()) : $mainGallery->the_post();
  10. $mainGalleryPic = get_children(array(
  11. 'post_parent' => get_the_ID(),
  12. 'post_type' => 'attachment',
  13. 'numberposts' => 1,
  14. 'order' => 'DESC',
  15. 'orderby' => 'date',
  16. 'post_mime_type' => 'image'));
  17.  
  18. foreach($mainGalleryPic as $listele ) {
  19. $img=wp_get_attachment_image_src($listele->ID, 'mainProjects');
  20. $cap=$listele->post_title;
  21. }
  22. ?>
  23. <!-- BLOCK -->
  24. <div class="block <?php if($i==1) { echo 'noBg noPadl'; } elseif($i==5) { echo 'noMarr'; } ?>">
  25. <h2>NEWEST</h2>
  26. <h3><?php the_title(); ?></h3>
  27. <h4>Online</h4>
  28. <div class="thumb <?php if($i%2==0) { echo 'small'; } else { echo 'full'; } ?>">
  29. <img src="<?php echo $img[0]; ?>" alt="<?php the_title(); ?>">
  30. </div>
  31. <p><?php echo substr(get_the_content(),0,110); ?></p>
  32. <a href="<?php the_permalink(); ?>">Click for more</a>
  33. </div>
  34. <!-- /BLOCK -->
  35.  
  36. <?php $i++; endwhile; ?>
  37.  
  38. </div>
  39. <!-- /GALLERY VIEW-->

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.