Home Forums Free Themes Education Hub How to change length of text in slider

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6937
    Lauril
    Participant

    Hi, I would like to show more text in the preview pane on the slider but cannot find where to change that.

    #6951
    wensolutions
    Keymaster

    Hello,
    Please make a child theme to keep your changes safe add the following code on your child themes function.php file

    function education_hub_get_slider_details( $input ) {
    
    		$featured_slider_type   = education_hub_get_option( 'featured_slider_type' );
    		$featured_slider_number = education_hub_get_option( 'featured_slider_number' );
    
    		switch ( $featured_slider_type ) {
    
    			case 'featured-page':
    
    				$ids = array();
    
    				for ( $i = 1; $i <= $featured_slider_number ; $i++ ) {
    					$id = education_hub_get_option( 'featured_slider_page_' . $i );
    					if ( ! empty( $id ) ) {
    						$ids[] = absint( $id );
    					}
    				}
    				// Bail if no valid pages are selected.
    				if ( empty( $ids ) ) {
    					return $input;
    				}
    
    				$qargs = array(
    					'posts_per_page' => esc_attr( $featured_slider_number ),
    					'no_found_rows'  => true,
    					'orderby'        => 'post__in',
    					'post_type'      => 'page',
    					'post__in'       => $ids,
    					'meta_query'     => array(
    						array( 'key' => '_thumbnail_id' ), // Show only posts with featured images.
    					),
    				);
    
    				// Fetch posts.
    				$all_posts = get_posts( $qargs );
    				$slides = array();
    
    				if ( ! empty( $all_posts ) ) {
    
    					$cnt = 0;
    					foreach ( $all_posts as $key => $post ) {
    
    						if ( has_post_thumbnail( $post->ID ) ) {
    							$image_array = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'education-hub-slider' );
    							$slides[ $cnt ]['images']  = $image_array;
    							$slides[ $cnt ]['title']   = esc_html( $post->post_title );
    							$slides[ $cnt ]['url']     = esc_url( get_permalink( $post->ID ) );
    							$slides[ $cnt ]['excerpt'] = education_hub_the_excerpt( apply_filters( 'education_hub_filter_slider_caption_length', 50 ), $post );
    
    							$cnt++;
    						}
    					}
    				}
    				if ( ! empty( $slides ) ) {
    					$input = $slides;
    				}
    
    			break;
    
    			default:
    			break;
    		}
    		return $input;
    
    	}

    then change the number besides ‘education_hub_filter_slider_caption_length’ which is now 50 to your required number of words you want to show.

    Hope this helps

    #7034
    Lauril
    Participant

    Thank you! I’ll give it a try.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.