Home › Forums › Pro Themes › Education Hub Pro › Featured content
Tagged: Homepage
- This topic has 5 replies, 2 voices, and was last updated 8 years, 2 months ago by wensolutions.
-
AuthorPosts
-
September 17, 2016 at 11:27 am #17848UliParticipant
I do not need as much space for text below the image. How can I limit the text shown under the image. Is it possible to link from the text to the further content.
Thanks!uli
September 18, 2016 at 7:45 am #17901wensolutionsKeymasterHi @
You can put the following custom CSS in the Custom CSS field option in the Advance Options -> Customize.
#featured-news-events { display: none; } div#content.site-content { display: none; }
Hope this helps !
Thanks
September 19, 2016 at 2:48 pm #18010UliParticipantThanks for your help!
Perhaps I have not explained it good enough. Next try: On the frontpage I have four sections of featured content with pictures. Under the pictures, the first 10 lines or so of text from the featured content page is visible here. My wish is to have for example only five lines or 50px or something else.
At the end of the text there are points giving the hint to the continued text on the featured content page. But there ist no active link there, the link is only on the picture above.
Is it possible to have the link at the end of the text, or at the word “more” or so.Thanks for helping and I apologize for the circumstances.
uli
September 20, 2016 at 1:55 am #18050wensolutionsKeymasterHello @Uli,
To decrease the excerpt content length and add read more link in the featured post area you will first need to create a child theme of the Education Hub Pro theme. If you need reference on creating and using child theme, please use this link as the reference : https://codex.wordpress.org/Child_Themes.
After creating and activating your child theme, go to the child theme directory and paste in the following codes in your child theme’s functions.php file:
function education_hub_modified_the_excerpt( $length = 40, $post_obj = null ) { global $post; if ( is_null( $post_obj ) ) { $post_obj = $post; } $length = absint( $length ); if ( $length < 1 ) { $length = 40; } $source_content = $post_obj->post_content; if ( ! empty( $post_obj->post_excerpt ) ) { $source_content = $post_obj->post_excerpt; } $source_content = preg_replace( '<code>\[[^\]]*\]</code>', '', $source_content ); $read_more_link = sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $post_obj->ID ) ), __( ' Read More', 'education-hub' ) ); $trimmed_content = wp_trim_words( $source_content, $length, $read_more_link ); return $trimmed_content; } function education_hub_get_featured_content_details( $input ) { $featured_content_type = education_hub_get_option( 'featured_content_type' ); $featured_content_number = education_hub_get_option( 'featured_content_number' ); switch ( $featured_content_type ) { case 'featured-page': $ids = array(); for ( $i = 1; $i <= $featured_content_number ; $i++ ) { $id = education_hub_get_option( 'featured_content_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_content_number ), 'no_found_rows' => true, 'orderby' => 'post__in', 'post_type' => 'page', 'post__in' => $ids, ); // Fetch posts. $all_posts = get_posts( $qargs ); $contents = array(); if ( ! empty( $all_posts ) ) { $cnt = 0; foreach ( $all_posts as $key => $post ) { $image_array = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'education-hub-thumb' ); $contents[ $cnt ]['images'] = $image_array; $contents[ $cnt ]['title'] = esc_html( $post->post_title ); $contents[ $cnt ]['url'] = esc_url( get_permalink( $post->ID ) ); $contents[ $cnt ]['excerpt'] = education_hub_modified_the_excerpt( apply_filters( 'education_hub_filter_featured_modified_content_excerpt_length', 20 ), $post ); $cnt++; } } if ( ! empty( $contents ) ) { $input = $contents; } break; case 'featured-post': $ids = array(); for ( $i = 1; $i <= $featured_content_number ; $i++ ) { $id = education_hub_get_option( 'featured_content_post_' . $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_content_number ), 'no_found_rows' => true, 'orderby' => 'post__in', 'post__in' => $ids, ); // Fetch posts. $all_posts = get_posts( $qargs ); $contents = array(); if ( ! empty( $all_posts ) ) { $cnt = 0; foreach ( $all_posts as $key => $post ) { $image_array = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'education-hub-thumb' ); $contents[ $cnt ]['images'] = $image_array; $contents[ $cnt ]['title'] = esc_html( $post->post_title ); $contents[ $cnt ]['url'] = esc_url( get_permalink( $post->ID ) ); $contents[ $cnt ]['excerpt'] = education_hub_modified_the_excerpt( apply_filters( 'education_hub_filter_featured_modified_content_excerpt_length', 20 ), $post ); $cnt++; } } if ( ! empty( $contents ) ) { $input = $contents; } break; case 'demo-content': $demo_contents = array( array( 'title' => __( 'Featured Content One', 'education-hub' ), 'excerpt' => __( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam quis metus scelerisque, faucibus risus eu, luctus est. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse ultricies nunc porttitor, rutrum libero quis, gravida odio. Donec tempus dui nec nisi fringilla, vitae efficitur risus cursus. Nam ultricies congue quam, non pellentesque ipsum mollis vel.', 'education-hub' ), 'url' => esc_url( home_url( '/' ) ), ), array( 'title' => __( 'Featured Content Two', 'education-hub' ), 'excerpt' => __( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam quis metus scelerisque, faucibus risus eu, luctus est. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse ultricies nunc porttitor, rutrum libero quis, gravida odio. Donec tempus dui nec nisi fringilla, vitae efficitur risus cursus. Nam ultricies congue quam, non pellentesque ipsum mollis vel.', 'education-hub' ), 'url' => esc_url( home_url( '/' ) ), ), array( 'title' => __( 'Featured Content Three', 'education-hub' ), 'excerpt' => __( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam quis metus scelerisque, faucibus risus eu, luctus est. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse ultricies nunc porttitor, rutrum libero quis, gravida odio. Donec tempus dui nec nisi fringilla, vitae efficitur risus cursus. Nam ultricies congue quam, non pellentesque ipsum mollis vel.', 'education-hub' ), 'url' => esc_url( home_url( '/' ) ), ), array( 'title' => __( 'Featured Content Four', 'education-hub' ), 'excerpt' => __( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam quis metus scelerisque, faucibus risus eu, luctus est. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse ultricies nunc porttitor, rutrum libero quis, gravida odio. Donec tempus dui nec nisi fringilla, vitae efficitur risus cursus. Nam ultricies congue quam, non pellentesque ipsum mollis vel.', 'education-hub' ), 'url' => esc_url( home_url( '/' ) ), ), ); $input = $demo_contents; $input = array_slice( $demo_contents, 0, absint( $featured_content_number ) ); break; default: break; } return $input; }
The code will decrease the no of words displayed in the excerpt of the Featured post section and will also add a “Read More” link to each of them.
Hope this resolves your issue,
Best Regards !!
September 20, 2016 at 4:14 pm #18101UliParticipantwow, thats`s great!!
thank you very much!
Best regards
uliSeptember 20, 2016 at 11:45 pm #18140wensolutionsKeymasterHello @Uli
We are very glad to hear that your issue has been resolved.
If you have any further query regarding the theme never hesitate to post your query.Regards,
CHEERS!!!! -
AuthorPosts
- You must be logged in to reply to this topic.