Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // img src for
- <img src="<?php
- $thumb_id = get_post_thumbnail_id();
- $thumb_url = wp_get_attachment_image_src($thumb_id,'promo_img_size', array('class' => 'promo_portfolio', true));
- echo $thumb_url[0];
- ?>" alt="" />
- /*****************************and usages in shortcode**********************************************/
- // usages of news ticker as a shortcode
- if(! function_exists('owl_carousel_shortcode')):
- function owl_carousel_shortcode($atts){
- extract( shortcode_atts( array(
- 'category' => '', // category by default
- 'count' => '10' // default post 10
- ), $atts, 'items_do_shortcode' ) ); // this is for do_shortcode where we have to query(to show post)
- $q = new WP_Query(
- array('posts_per_page' => -1,
- 'post_type' => 'owl_post', // custom post type
- 'category_name'=>$category,
- //'order'=>'ASC' //this is for price order
- )
- );
- $list = '<div class="owl-demo">'; // wrapper will go here
- while($q->have_posts()) : $q->the_post();
- $thumb_id = get_post_thumbnail_id();
- $thumb_url = wp_get_attachment_image_src($thumb_id,'owl-carousel-size', array('class' => 'promo_portfolio', true));
- $list .= '
- <div class="item"><img src="'.$thumb_url[0].'" alt="hello"/></div>
- ';
- endwhile;
- $list.= '</div>';
- wp_reset_query();
- return $list;
- }
- add_shortcode('owl_carousel','owl_carousel_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement