Guest User

Untitled

a guest
Jan 20th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <?php
  2.  
  3. global $post;
  4. $args = array( 'posts_per_page' => -1, 'category_name' => 'parents' );
  5.  
  6. $myposts = get_posts( $args );
  7. foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
  8.  
  9. <h3 class=""><?php the_title(); ?></h3>
  10. <div class="">
  11. <?php the_post_thumbnail( array(500, 300)); ?>
  12. <div class="">
  13. <?php $media = get_attached_media( 'image');
  14. $media_first = array_shift( $media );
  15. $image_url = $media_first->guid;
  16. echo '<a href="'. $image_url .'" class="" >Посмотреть</a>';
  17.  
  18. foreach ($media as $k => $v) {
  19. $image_urls = $v->guid;
  20. echo '<a href="'. $image_urls .'" ></a>';
  21. }
  22. ?>
  23. </div>
  24. </div>
  25.  
  26. <?php add_filter('the_content', 'strip_images',2); ?>
  27. <?php the_content(); ?>
  28.  
  29. <?php endforeach;
  30. wp_reset_postdata();?>
  31.  
  32. //functions.php
  33. <?php function strip_images($content){
  34. return preg_replace('/<img[^>]+./','',$content);
  35. } ?>
Add Comment
Please, Sign In to add comment