-
AuthorPosts
-
July 8, 2014 at 3:20 am #66185
Hi there,
Firstly, fantastic theme (visually, ease of use, features).
I am using the [recent posts] shortcode, and appreciate the various options for orientation, categories, etc. The thing is, none of them provide the option to allow an excerpt to show (only the option of an image or not).
I’m assuming this isn’t a feature, yet, so is there a way to do this within certain php files?
On my homepage I have several different [recent posts] categories in separate columns. I would like to only show the excerpt on the main ‘News’ posts (of the news category).
Please let me know if there is a way to do this.
Thanks,
RobJuly 8, 2014 at 4:59 pm #66448I’m also very much interested in finding a solution to this. It would be great if I could display the post titles on multiple rows, and to display an excerpt of the post content as well.
July 8, 2014 at 10:41 pm #66514Hey guys,
This is feature isn’t currently supported but we have taken note of this as feature request and might implement it in a future release.
Thanks.
July 9, 2014 at 4:20 am #66578Thanks for your reply, but that’s not very helpful.
I don’t mind signing a disclaimer of any sort that says it’s my fault if I ‘break’ my website. Can’t you suggest a workaround for the moment?
Would I edit the x-shortcode file, or would I make a new page template?
If so, where would I get the code to put there?
July 9, 2014 at 10:08 pm #66964Hi Rob,
Just paste this code at your child theme’s functions.php then use enable_excerpt=”true” attribute to your shortcode (eg. [recent_posts enable_excerpt=”true” ] ). Please note that switching from classic to visual composer may remove this attribute since this is not default option.
function x_shortcode_recent_posts_v2code( $atts ) { extract( shortcode_atts( array( 'id' => '', 'class' => '', 'style' => '', 'type' => '', 'count' => '', 'category' => '', 'enable_excerpt' => '', 'offset' => '', 'orientation' => '', 'no_image' => '', 'fade' => '' ), $atts ) ); $id = ( $id != '' ) ? 'id="' . esc_attr( $id ) . '"' : ''; $class = ( $class != '' ) ? 'x-recent-posts cf ' . esc_attr( $class ) : 'x-recent-posts cf'; $style = ( $style != '' ) ? 'style="' . $style . '"' : ''; $type = ( $type == 'portfolio' ) ? 'x-portfolio' : 'post'; $count = ( $count != '' ) ? $count : 3; $category = ( $category != '' ) ? $category : ''; $category_type = ( $type == 'post' ) ? 'category_name' : 'portfolio-category'; $offset = ( $offset != '' ) ? $offset : 0; $orientation = ( $orientation != '' ) ? ' ' . $orientation : ' horizontal'; $no_image = ( $no_image == 'true' ) ? $no_image : ''; $fade = ( $fade == 'true' ) ? $fade : 'false'; $enable_excerpt = ( $enable_excerpt == 'true' ) ? true : false; $output = "<div {$id} class=\"{$class}{$orientation}\" {$style} data-fade=\"{$fade}\">"; $q = new WP_Query( array( 'orderby' => 'date', 'post_type' => "{$type}", 'posts_per_page' => "{$count}", 'offset' => "{$offset}", "{$category_type}" => "{$category}" ) ); if ( $q->have_posts() ) : while ( $q->have_posts() ) : $q->the_post(); if ( $no_image == 'true' ) { $image_output = ''; $image_output_class = 'no-image'; } else { $image_output = '<div class="x-recent-posts-img">' . get_the_post_thumbnail( get_the_ID(), 'entry-' . get_theme_mod( 'x_stack' ) . '-cropped', NULL ) . '</div>'; $image_output_class = 'with-image'; } $output .= '<a class="x-recent-post' . $count . ' ' . $image_output_class . '" href="' . get_permalink( get_the_ID() ) . '" title="' . esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ) . '">' . '<article id="post-' . get_the_ID() . '" class="' . implode( ' ', get_post_class() ) . '">' . '<div class="entry-wrap">' . $image_output . '<div class="x-recent-posts-content">' . '<h3 class="h-recent-posts">' . get_the_title() . '</h3>' . '<span class="x-recent-posts-date">' . get_the_date() . '</span>' . ( $enable_excerpt ? '<span class="x-recent-posts-excerpt">' . strip_tags( get_the_excerpt() ) . '</span>' : '' ) . '</div>' . '</div>' . '</article>' . '</a>'; endwhile; endif; wp_reset_postdata(); $output .= '</div>'; return $output; } add_action('wp_head', 'change_recent_posts_to_v2'); function change_recent_posts_to_v2() { remove_shortcode( 'recent_posts' ); add_shortcode( 'recent_posts', 'x_shortcode_recent_posts_v2code' ); }
Let us know how it goes.
July 10, 2014 at 6:46 am #67092Hello,
I am using the renew stack. I created a child theme, added the above code to the functions.php and also the attribute shortcode to my shortcode. But nothing happened. No expert is showing under my recent post.
Did I do add in the attribute wrong?
[recent_posts type=”post” enable_excerpt=”true” count=”3″ orientation=”horizontal” category=”Love”]Thanks.
July 11, 2014 at 8:40 am #67479Hi Tricia,
Thank you for writing in!
It seems that the enable_excerpt attribute that you have used is having prettyquotes which may cause the issue. Instead please try using the following [recent_posts] code:
[recent_posts type="post" enable_excerpt="true" count="3" orientation="horizontal" category="Love"]
Hope this helps. If you still face any issue, please let us know. We’ll be happy to assist. 🙂
Thank you.
July 25, 2014 at 8:49 am #73431Hi! I just tried this solution and it works except for one thing: the excerpt losing the formatting. So if I have something H-tagged, bolded, or on two lines, etc., that all gets lost in the excerpt. Is there a way to have the excerpt appear formatted? Thanks!
July 26, 2014 at 8:17 pm #73891Hi Jennifer,
Excerpts are just plain text, and that is how wordpress works. And you might need additional plugins to do that like http://wordpress.org/plugins/advanced-excerpt/
Thanks!
October 6, 2014 at 12:22 am #119087Hello, I having trouble getting the excerpts to appear using the integrity stack on vertical mode, can you help me out? Thanks.
All I have done so far is added the post_exerpts=”true” to the short code, do I need to do anything else? Thanks.
October 6, 2014 at 2:53 am #119155Hi,
You need to set-up a child theme using this guide http://theme.co/x/member/kb/how-to-setup-child-themes/
Then you need to add the code below in child theme functions.php
For post_exerpts=”true” to work
function x_shortcode_recent_posts_v2code( $atts ) { extract( shortcode_atts( array( 'id' => '', 'class' => '', 'style' => '', 'type' => '', 'count' => '', 'category' => '', 'enable_excerpt' => '', 'offset' => '', 'orientation' => '', 'no_image' => '', 'fade' => '' ), $atts ) ); $id = ( $id != '' ) ? 'id="' . esc_attr( $id ) . '"' : ''; $class = ( $class != '' ) ? 'x-recent-posts cf ' . esc_attr( $class ) : 'x-recent-posts cf'; $style = ( $style != '' ) ? 'style="' . $style . '"' : ''; $type = ( $type == 'portfolio' ) ? 'x-portfolio' : 'post'; $count = ( $count != '' ) ? $count : 3; $category = ( $category != '' ) ? $category : ''; $category_type = ( $type == 'post' ) ? 'category_name' : 'portfolio-category'; $offset = ( $offset != '' ) ? $offset : 0; $orientation = ( $orientation != '' ) ? ' ' . $orientation : ' horizontal'; $no_image = ( $no_image == 'true' ) ? $no_image : ''; $fade = ( $fade == 'true' ) ? $fade : 'false'; $enable_excerpt = ( $enable_excerpt == 'true' ) ? true : false; $output = "<div {$id} class=\"{$class}{$orientation}\" {$style} data-fade=\"{$fade}\">"; $q = new WP_Query( array( 'orderby' => 'date', 'post_type' => "{$type}", 'posts_per_page' => "{$count}", 'offset' => "{$offset}", "{$category_type}" => "{$category}" ) ); if ( $q->have_posts() ) : while ( $q->have_posts() ) : $q->the_post(); if ( $no_image == 'true' ) { $image_output = ''; $image_output_class = 'no-image'; } else { $image_output = '<div class="x-recent-posts-img">' . get_the_post_thumbnail( get_the_ID(), 'entry-' . get_theme_mod( 'x_stack' ) . '-cropped', NULL ) . '</div>'; $image_output_class = 'with-image'; } $output .= '<a class="x-recent-post' . $count . ' ' . $image_output_class . '" href="' . get_permalink( get_the_ID() ) . '" title="' . esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ) . '">' . '<article id="post-' . get_the_ID() . '" class="' . implode( ' ', get_post_class() ) . '">' . '<div class="entry-wrap">' . $image_output . '<div class="x-recent-posts-content">' . '<h3 class="h-recent-posts">' . get_the_title() . '</h3>' . '<span class="x-recent-posts-date">' . get_the_date() . '</span>' . ( $enable_excerpt ? '<span class="x-recent-posts-excerpt">' . strip_tags( get_the_excerpt() ) . '</span>' : '' ) . '</div>' . '</div>' . '</article>' . '</a>'; endwhile; endif; wp_reset_postdata(); $output .= '</div>'; return $output; } add_action('wp_head', 'change_recent_posts_to_v2'); function change_recent_posts_to_v2() { remove_shortcode( 'recent_posts' ); add_shortcode( 'recent_posts', 'x_shortcode_recent_posts_v2code' ); }
October 16, 2014 at 3:05 pm #126597Thank you.
October 16, 2014 at 8:36 pm #126767You’re welcome 🙂
December 8, 2014 at 6:32 am #160297Thanks. I am still having some issues.
I did include the following code to my functions.php file on my child theme:
function x_shortcode_recent_posts_v2code( $atts ) { extract( shortcode_atts( array( 'id' => '', 'class' => '', 'style' => '', 'type' => '', 'count' => '', 'category' => '', 'enable_excerpt' => '', 'offset' => '', 'orientation' => '', 'no_image' => '', 'fade' => '' ), $atts ) ); $id = ( $id != '' ) ? 'id="' . esc_attr( $id ) . '"' : ''; $class = ( $class != '' ) ? 'x-recent-posts cf ' . esc_attr( $class ) : 'x-recent-posts cf'; $style = ( $style != '' ) ? 'style="' . $style . '"' : ''; $type = ( $type == 'portfolio' ) ? 'x-portfolio' : 'post'; $count = ( $count != '' ) ? $count : 3; $category = ( $category != '' ) ? $category : ''; $category_type = ( $type == 'post' ) ? 'category_name' : 'portfolio-category'; $offset = ( $offset != '' ) ? $offset : 0; $orientation = ( $orientation != '' ) ? ' ' . $orientation : ' horizontal'; $no_image = ( $no_image == 'true' ) ? $no_image : ''; $fade = ( $fade == 'true' ) ? $fade : 'false'; $enable_excerpt = ( $enable_excerpt == 'true' ) ? true : false; $output = "<div {$id} class=\"{$class}{$orientation}\" {$style} data-fade=\"{$fade}\">"; $q = new WP_Query( array( 'orderby' => 'date', 'post_type' => "{$type}", 'posts_per_page' => "{$count}", 'offset' => "{$offset}", "{$category_type}" => "{$category}" ) ); if ( $q->have_posts() ) : while ( $q->have_posts() ) : $q->the_post(); if ( $no_image == 'true' ) { $image_output = ''; $image_output_class = 'no-image'; } else { $image_output = '<div class="x-recent-posts-img">' . get_the_post_thumbnail( get_the_ID(), 'entry-' . get_theme_mod( 'x_stack' ) . '-cropped', NULL ) . '</div>'; $image_output_class = 'with-image'; } $output .= '<a class="x-recent-post' . $count . ' ' . $image_output_class . '" href="' . get_permalink( get_the_ID() ) . '" title="' . esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ) . '">' . '<article id="post-' . get_the_ID() . '" class="' . implode( ' ', get_post_class() ) . '">' . '<div class="entry-wrap">' . $image_output . '<div class="x-recent-posts-content">' . '<h3 class="h-recent-posts">' . get_the_title() . '</h3>' . '<span class="x-recent-posts-date">' . get_the_date() . '</span>' . ( $enable_excerpt ? '<span class="x-recent-posts-excerpt">' . strip_tags( get_the_excerpt() ) . '</span>' : '' ) . '</div>' . '</div>' . '</article>' . '</a>'; endwhile; endif; wp_reset_postdata(); $output .= '</div>'; return $output; } add_action('wp_head', 'change_recent_posts_to_v2'); function change_recent_posts_to_v2() { remove_shortcode( 'recent_posts' ); add_shortcode( 'recent_posts', 'x_shortcode_recent_posts_v2code' ); }
My Silo1 Blog landing page contains only this code:
[recent_posts type="post" category="vou-me-casar,fotos-de-casamento" count="3" offset="1" orientation="horizontal" enable_excerpt=”true” no_image="false" fade="true"]
I have even include content to the Excerpt field in the Blog posts, I’ve clear my browser cache and when I load the Silo1-Blog Landing page, I can’t see any excerpt below the Blog Post Thumbnail…
Also, I still see the Date on the Blog Post Thumbnail, even though I have included a code that support has provided in the functions.php file on my Child Theme that gets rid off the Post Writer and the Date.
I can confirm that the functions.php is being read off of my Child Theme, because the Posts doesn’t show the Author and Date anymore.
Am I missing something?
Regards,
Paulo Tebet
December 8, 2014 at 6:50 am #160308Hi Paulo,
Thanks for writing in! To assist you with this issue, we’ll first need you to provide us with your URL as stated on the forum entrance page. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.
-
AuthorPosts