-
AuthorPosts
-
October 11, 2015 at 6:50 am #620206
Could you please advise on how to add “read more” after manual except within x-child-theme?
This is a two part solution form WordPress.. but how will the second “remove filter” part look for x-theme?
Thank you.
October 11, 2015 at 7:24 am #620234Hi there,
Please add this in functions.php :
// Excerpt More String // ============================================================================= if ( ! function_exists( 'x_excerpt_string' ) ) : function x_excerpt_string( $more ) { $stack = x_get_stack(); if ( $stack == 'integrity' ) { return ' ... <div><a href="' . get_permalink() . '" class="more-link">' . __( 'Read More', '__x__' ) . '</a></div>'; } else if ( $stack == 'renew' ) { return ' ... <a href="' . get_permalink() . '" class="more-link">' . __( 'Read More', '__x__' ) . '</a>'; } else if ( $stack == 'icon' ) { return ' ...'; } else if ( $stack == 'ethos' ) { return ' ... <div><a href="' . get_permalink() . '" class="more-link">' . __( 'Read More', '__x__' ) . '</a></div>'; } } add_filter( 'excerpt_more', 'x_excerpt_string' ); endif;
Hope it helps.
November 2, 2015 at 8:25 am #649294Hi, I followed the steps and pasted the above mentioned code to functions.php but this does not work for me. Please look at the first post on http://www.outlineofphotography.com
Regards
VarunNovember 2, 2015 at 10:07 am #649420Hi Varun,
Thanks for updating. Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / password
– FTP credentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
November 2, 2015 at 10:21 am #649446This reply has been marked as private.November 2, 2015 at 12:35 pm #649631Hi again,
Thank you for the credentials, Please replace the previous code with this one in your child theme’s functions.php file:
function custom_excerpt($text) { // custom 'read more' link if (strpos($text, '[...]')) { $excerpt = strip_tags(str_replace('[...]', '... <a href="'.get_permalink().'">Read More...</a>', $text), "<a>"); } else { $excerpt = '<p>' . $text . '<a href="'.get_permalink().'">Read More...</a></p>'; } return $excerpt; } add_filter('the_excerpt', 'custom_excerpt');
Let us know how this goes!
November 3, 2015 at 3:47 am #650504This reply has been marked as private.November 3, 2015 at 3:50 am #650513This reply has been marked as private.November 3, 2015 at 4:32 am #650545Hi Varun,
Try adding following CSS under Customize > Custom > CSS:
.more-link { display: none; }
Hope it helps ๐
November 3, 2015 at 6:22 am #650634Works, great! thanks a lot! Much appreciated.
Regards
VarunNovember 3, 2015 at 6:28 am #650645You’re most welcome.
Feel free to ask us again. Have a great day! ๐
November 11, 2015 at 5:10 pm #661728The second set of code above worked well for me! Is there anyway for the “Read More…” to display at the end of the text sentence? Also, can I make the font weight bolder so it’s easier to read?
Thanks!!
November 11, 2015 at 8:51 pm #661947Hi Ashley,
Thanks for updating this thread!
Please use this code instead:
function custom_excerpt($text) { // custom 'read more' link if (strpos($text, '[...]')) { $excerpt = strip_tags(str_replace('[...]', '... <a href="'.get_permalink().'">Read More...</a>', $text), "<a>"); } else { $excerpt = '<p>' . strip_tags($text) . '<a class="read-more" href="'.get_permalink().'">Read More...</a></p>'; } return $excerpt; } add_filter('the_excerpt', 'custom_excerpt');
And if there is a need to change the colors of the read more text, you can insert this code in your child themeโs style.css
.site a.read-more { color: red; } .site a.read-more:hover { color: green; }
Feel free to change the colors. We would loved to know if this has work for you. Thank you.
-
AuthorPosts