-
AuthorPosts
-
April 23, 2015 at 7:58 pm #257090
Hello There,
Could you try another approach by using this custom excerpt function.
// ============================================================================= // Custom Excerpt Length - Call: echo excerpt($length); // ============================================================================= function limit_excerpt($limit) { $excerpt = explode(' ', get_the_excerpt(), $limit); if (count($excerpt)>=$limit) { array_pop($excerpt); $excerpt = implode(" ",$excerpt).'.'; } else { $excerpt = implode(" ",$excerpt); } return $excerpt; }
And you use it in your custom recent shortcode by replacing this code:
$enable_excerpt ? '<span class="x-recent-posts-excerpt">' . strip_tags( get_the_excerpt() ) . '</span>' : '';
With this code
$enable_excerpt ? '<span class="x-recent-posts-excerpt">' . strip_tags( limit_excerpt(30) ) . '</span>' : '';
Please let us know how it goes.
April 24, 2015 at 1:11 pm #257731It seems like the link I shared worked in my function.php, still, I think I might have figured it out that the “Read More” css style not showing up might have something to do with that .x-recent-posts a class overwriting the .more-link class.
However, I think it’s best to somehow edit the code in function.php. I tried to do that but I didn’t have any success….
April 24, 2015 at 1:14 pm #257735Oh sorry, I didn’t see the last message from 7:58pm. The link I shared works. It’s just that the css style for “Read More” isn’t showing up….
April 24, 2015 at 9:32 pm #258002Hi there,
Thanks for updating the thread! You can add this under Custom > CSS in the Customizer or in your child theme’s style.css file.
.readm { color:#F15A24; } .readm:hover { color:#000000; cursor: pointer; }
You can add this under Custom > JavaScript in the Customizer.
jQuery ( function( $ ) { $(document).ready(function() { $(".x-recent-posts.cf.vertical span").each ( function() { $( this ).html( $( this ).text().replace(/\Read More/g,'<span class="readm">Read More</span>')); } ); }); } );
Hope this helps – thanks!
April 27, 2015 at 10:29 am #259676That didn’t work. So I tried to edit the function.php again and I succeed. What I did was to edit the return to ”.
// Excerpt More String // ============================================================================= if ( ! function_exists( 'x_excerpt_string' ) ) : function x_excerpt_string( $more ) { $stack = x_get_stack(); if ( $stack == 'integrity' ) { return ''; } else if ( $stack == 'renew' ) { return ''; } else if ( $stack == 'icon' ) { return ' ...'; } else if ( $stack == 'ethos' ) { return ' ...'; } } add_filter( 'excerpt_more', 'x_excerpt_string' ); endif; // Content More String // ============================================================================= if ( ! function_exists( 'x_content_string' ) ) : function x_content_string( $more ) { return ''; } add_filter( 'the_content_more_link', 'x_content_string' ); endif;
and then edited the .excerpt to show
. ( $enable_excerpt ? '<span class="x-recent-posts-excerpt">' . strip_tags( get_the_excerpt() ) . '</span>' . ' ' . '<span class="more-link">' . __( 'Read More', '__x__' ) . '</span>' : '' )
As you can see, it works now. Thank you for all your help too.
April 27, 2015 at 12:34 pm #259770Glad you’ve sorted it out. You’re most welcome.
-
AuthorPosts