Advertisement
firoze

insert image by src <img src=" " />

Jun 9th, 2015
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. // img src for
  2.  
  3. <img src="<?php
  4. $thumb_id = get_post_thumbnail_id();
  5. $thumb_url = wp_get_attachment_image_src($thumb_id,'promo_img_size', array('class' => 'promo_portfolio', true));
  6. echo $thumb_url[0];
  7. ?>" alt="" />
  8.  
  9.  
  10. /*****************************and usages in shortcode**********************************************/
  11.  
  12. // usages of news ticker as a shortcode
  13.  
  14. if(! function_exists('owl_carousel_shortcode')):
  15. function owl_carousel_shortcode($atts){
  16. extract( shortcode_atts( array(
  17. 'category' => '', // category by default
  18. 'count' => '10' // default post 10
  19. ), $atts, 'items_do_shortcode' ) ); // this is for do_shortcode where we have to query(to show post)
  20.  
  21. $q = new WP_Query(
  22. array('posts_per_page' => -1,
  23. 'post_type' => 'owl_post', // custom post type
  24. 'category_name'=>$category,
  25. //'order'=>'ASC' //this is for price order
  26.  
  27. )
  28. );
  29.  
  30.  
  31. $list = '<div class="owl-demo">'; // wrapper will go here
  32. while($q->have_posts()) : $q->the_post();
  33. $thumb_id = get_post_thumbnail_id();
  34. $thumb_url = wp_get_attachment_image_src($thumb_id,'owl-carousel-size', array('class' => 'promo_portfolio', true));
  35. $list .= '
  36. <div class="item"><img src="'.$thumb_url[0].'" alt="hello"/></div>
  37. ';
  38. endwhile;
  39. $list.= '</div>';
  40. wp_reset_query();
  41. return $list;
  42. }
  43. add_shortcode('owl_carousel','owl_carousel_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement