badget

Biggest Sale! Special Offer!

Get 30% discount on all of our single themes with this coupon code: #30%SALE

Hurry up! *Limited time offer*

Reply To: Promobox with full width and Featured Clients / Products opening in same tab

#36661

Hi Manuel,

We need to say that it needs code customization. If you are good at coding then you can easily customize the code by creating child theme. If you cannot create a child theme then first make a folder ambition-pro-child. Under that folder create a style.css file and functions.php file.
Add below code inside style.css file

/*
Theme Name: Ambition Pro Child Theme
Author: Self-Help WordPress User
Template: ambition
*/

@import url("../ambition/style.css"); 

Under functions.php file of the child theme, create your widgets and register them. Just copy the parent widget, change the name of widget TH: Featured Clients/ Products to TH Child: Featured Clients/ Products, make customisation and create your custom widget. If you do this, the widgets of parent theme and child both will appear. Use your custom widget of child theme instead of the parent theme.

Just add this below code in your functions.php file

<?php 
register_widget("ambition_featured_image__child_widget");

/*********************************************************************************************************/
class ambition_featured_image__child_widget extends WP_Widget {
	function ambition_featured_image__child_widget() {
		$widget_ops = array( 'classname' => 'widget_ourclients', 'description' => __( 'Display Featured Clients/ Products ( Business Layout )', 'ambition') );
		$control_ops = array('width' => 200, 'height' => 250);
		parent::__construct( false, $name='TH Child: Featured Clients/ Products', $widget_ops, $control_ops );
	}
	function form( $instance ) {		
		$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'number' => '5', 'path0' => '', 'path1' => '', 'path2' => '', 'path3' => '', 'path4' => '', 'path5' => '', 'redirectlink0' => '', 'redirectlink1' => '', 'redirectlink2' => '', 'redirectlink3' => '', 'redirectlink4' => '', 'redirectlink5' => '') );	
		$title = strip_tags($instance['title']);
		$number = absint( $instance[ 'number' ] );	 
		for ( $i=0; $i<$number; $i++ ) {
			$var = 'path'.$i;
			$var1 = 'redirectlink'.$i;
			$instance[ $var ] = esc_url( $instance[ $var ] );
			$instance[ $var1 ] = esc_url( $instance[ $var1 ] );
		}		
		?>
		<p class="description">
			<?php _e( 'Note: Recommended size for the image is 400px (width) and 150px (height). If you want more image adding fields then first enter the number and click on Save, this will allow you more image adding fields', 'ambition' ); ?>
		</p>
		<p>
			<label for="<?php echo $this->get_field_id('title'); ?>">
				<?php _e('Image Title:', 'ambition'); ?>
			</label>
			<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
		</p>
		<p>
			<label for="<?php echo $this->get_field_id('number'); ?>">
				<?php _e( 'Number of Images:', 'ambition' ); ?>
			</label>
			<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" />
		</p>
		<?php for ( $i=0; $i<$number; $i++ ) {
			$var = 'path'.$i;
			$var1 = 'redirectlink'.$i;
			?>
			<p>
				<input type="text" class="upload1" id="<?php echo $this->get_field_id( $var ); ?>" name="<?php echo $this->get_field_name( $var ); ?>" value="<?php if(isset ( $instance[$var] ) ) echo esc_url( $instance[$var] ); ?>" />
				<input class="button  custom_media_button" name="<?php echo $this->get_field_name( $var ); ?>" type="button" id="custom_media_button_services" value="<?php echo esc_attr( 'Add Image'); ?>"onclick="mediaupload.uploader( '<?php echo $this->get_field_id( $var ); ?>' ); return false;"/>
				<br />
			</p>
			<p>
				<?php _e('Redirect Link:', 'ambition'); ?>
				<input class="widefat" name="<?php echo $this->get_field_name($var1); ?>" type="text" value="<?php if(isset ( $instance[$var1] ) ) echo esc_url( $instance[$var1] ); ?>" />
			</p>
			<?php } ?>
			<?php
		}
		function update( $new_instance, $old_instance ) {
			$instance = $old_instance;
			$instance['title'] = strip_tags($new_instance['title']);
			$instance['number'] = absint( $new_instance['number'] );

			for( $i=0; $i<$instance[ 'number' ]; $i++ ) {
				$var = 'path'.$i;
				$var1 = 'redirectlink'.$i;
				$instance[ $var] = esc_url_raw( $new_instance[ $var ] );			
				$instance[ $var1] = esc_url_raw( $new_instance[ $var1 ] );
			}
			return $instance;
		}	
		function widget( $args, $instance ) {
			extract($args);
			$title = empty( $instance['title'] ) ? '' : $instance['title'];
			$number = empty( $instance['number'] ) ? 5 : $instance['number'];
			$path_array = array();
			$redirectlink_array = array();
			for( $i=0; $i<$number; $i++ ) {
				$var = 'path'.$i;
				$var1 = 'redirectlink'.$i;
				$path = isset( $instance[ $var ] ) ? $instance[ $var ] : '';
				$redirectlink = isset( $instance[ $var1 ] ) ? $instance[ $var1 ] : ''; 			
			if( !empty( $path )  || !empty( $redirectlink ))  {		
				if( !empty( $path ) ){
 				array_push( $path_array, $path ); // Push the page id in the array
		 			}else{
		 			 array_push($path_array, "");
		 			}
	 			if( !empty( $redirectlink ) ){
	 				array_push( $redirectlink_array, $redirectlink ); // Push the page id in the array
		 			}else{
		 			 array_push($redirectlink_array, "");
		 			}
		 		}
	 		}
 		echo $before_widget;
 		if ( !empty( $path_array ) ) {
 			$output = '';
 			$output .= '<div class="container">';
 			$output .= '<ul>';
 			for( $i=0; $i<$number; $i++ ) {
 				$output .= '<li>';
 				if((!empty( $redirectlink_array[$i] )) || (!empty( $path_array[$i] )) ) {
 					$output .= '<a href="'.$redirectlink_array[$i].'" title="'.$title.'">
 					<img src="'.$path_array[$i].'" alt="'.$title.'">
 					</a>';
 				}
 				else {
 					if(!empty($path_array[$i])){
 						$output .= '<img src="'.$path_array[$i].'" alt="'.$title.'">';
 					}
 				}
 				$output .=	'</li>';
 			}
 			$output .= '</ul>';

 			$output .= '</div>';

 			echo $output;
 		}
 		echo $after_widget .'<!-- .widget_ourclients -->';
 	}
 }

Hope this may help you
Thank you!