• Resolved Annekee

    (@annekee)


    Hi, love this theme because it’s straight and simple. Yet I would like to have more text in the slider caption. How must I put this in function.php of my child theme to override the defailt length? Many thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @annekee

    You can copy following code to functions.php of your child theme:

    function business_era_get_slider_details() {
    
    		$output = array();
    
    		$slider_number = 5;
    
    		$page_ids = array();
    
    		for ( $i = 1; $i <= $slider_number ; $i++ ) {
    			$page_id = business_era_get_option( "slider_page_$i" );
    			if ( absint( $page_id ) > 0 ) {
    				$page_ids[] = absint( $page_id );
    			}
    		}
    
    		if ( empty( $page_ids ) ) {
    			return $output;
    		}
    
    		$query_args = array(
    			'posts_per_page' => count( $page_ids ),
    			'orderby'        => 'post__in',
    			'post_type'      => 'page',
    			'post__in'       => $page_ids,
    			'meta_query'     => array(
    				array( 'key' => '_thumbnail_id' ),
    			),
    		);
    
    		$posts = get_posts( $query_args );
    
    		if ( ! empty( $posts ) ) {
    			$p_count = 0;
    			foreach ( $posts as $post ) {
    				if ( has_post_thumbnail( $post->ID ) ) {
    					$image_array = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'business-era-slider' );
    					$output[ $p_count ]['image_url'] = $image_array[0];
    					$output[ $p_count ]['title']     = $post->post_title;
    					$output[ $p_count ]['url']       = get_permalink( $post->ID );
    					$output[ $p_count ]['excerpt']   = business_era_get_the_excerpt( 20, $post );
    					$p_count++;
    				}
    			}
    		}
    
    		return $output;
    	}

    Please change 20 to number of your requirement in above code business_era_get_the_excerpt( 20, $post );

    Thread Starter Annekee

    (@annekee)

    That is 100% perfect, and so fast, thank you so much Manesh!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘More text in slider caption’ is closed to new replies.