<?php
add_action( 'vc_before_init', 'rockon_services_WITHVS' );
function rockon_services_WITHVS() {
   vc_map( array(
      "name" => __("Custom Services Post",'rockon'),
      "base" => "rockon_services_post",
      "class" => "",
      "category" => __('Content','rockon'),
      'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
      'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
      "params" => array(
         array(
            "type" => "textfield",
            "holder" => "div",
            "class" => "",
            "heading" => __("Title",'rockon'),
            "param_name" => "title",
            "value" => __("Services",'rockon'),
            "description" => __("Title text Here.",'rockon')
         ),
         array(
            "type" => "dropdown",
            "holder" => "div",
            "class" => "",
            "heading" => __("Number Of Post",'rockon'),
            "param_name" => "no_of_post",
            "value" => array('3','6','9'),
            "description" => __("choose No of Post.",'rockon')
         )/*,
		 array(
            "type" => "textfield",
            "holder" => "div",
            "class" => "",
            "heading" => __("Change Text"),
            "param_name" => "readmore",
            "value" => __("Read More"),
            "description" => __("Read More Text Change Here.")
         )*/
      )
   ) );
}
add_shortcode( 'rockon_services_post', 'rockon_services_post_func' );
function rockon_services_post_func( $atts ) { // New function parameter $content is added!
   extract( shortcode_atts( array(
      'title' => 'something',
	  'no_of_post' => '3',
	  'readmore' => ''
   ), $atts ) );
   $result = $image = $svg = '';
   global $post;
   $result .= '<div class="rockon_service_main">';
   $services_query = new WP_Query( array( 'post_type' => 'services', 'posts_per_page' => $no_of_post) );
   if($services_query->have_posts()): 	
   $result .= ' <div class="row">';
		while($services_query->have_posts()) : $services_query->the_post();	
			$result .= '<div class="col-lg-4 col-md-4 col-sm-4"><div class="rockon_service">';
			$image = get_the_post_thumbnail( $post->ID, 'rockon-small-very-size' );
			if (has_post_thumbnail($post->ID) && !empty($image))
			{	
				$result .= '<div class="rock_service_icon">'.$image.'</div>';
			}else{
				$svg = get_post_meta( $post->ID, 'rockon_svgiconcode', true );
				if(!empty($svg)){
					$result .= '<div class="rock_service_icon">'.$svg.'</div>';
				}else{
					$result .= '<div class="rock_service_icon"><img src="'.ROCKON_PATH.'/images/no_image.jpg" class="rockon_nothumservices" alt=""></div>';
				}	
			}	
			$result .= '<h3>'.__(get_the_title($post->ID),'rockon').'</h3>
			<p>'.__(get_excerpt(200),'rockon').'</p>
			 </div>
			</div>';	
			$image = '';	
		 endwhile; 
	$result .= '</div>';
	endif; 
	$result .= '</div>';
	return $result;
   
}
?>