Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #358807

    sbromley
    Participant

    Two goals:

    1) ACCOMPLISHED: On blog index page, show at least some of the text content from the blog post that was created in Cornerstone. Achieved by changing blog customization to “Full Post Content on Index”.

    2) On the blog index page, DO NOT show the entire blog entry, instead show an excerpt followed by “Read More” link to the original blog post.

    I have not yet figured out #2. Can you help?

    I’ll post my login credentials next in case you need to get to the site.

    #358809

    sbromley
    Participant
    This reply has been marked as private.
    #358897

    Lely
    Moderator

    Hello There,

    Thanks for the admin credentials.
    I am a little confused on your number #1.
    For number 2.) You want this page:http://www.fatman365.com/blog/ to show just excerpt of the post and readmore and not the entire content. First, we have to set Full Post Content on Index via Appearance > Customizer > Blog > Full Post Content on Index to OFF. Post created using Cornerstone doesn’t show a normal excerpt. We have to set a manual excerpt. Click screen options on the upper right part of the post edit page then click Excerpts. It is because wordpress will strip out all html and shortcodes from the content and the content when using Cornerstone is wrapped inside a shortcode. So it stripped everything out. To generate automatic excerpt with readmore, it should be plain text which will not work with Cornerstone content. Your option is to use the normal editor to generate automatic excerpt and read more or use Cornerstone but set a manual excerpt. Then we have to add the following custom function in your child theme functions.php to generate readmore link for manual excerpts:

    //Read More Button For Excerpt
    function themprefix_excerpt_read_more_link($output) {
        global $post;
        return empty( $output ) ? $output : $output . ' <a href="' . get_permalink($post->ID) . '" class="more-link" title="Read More">Read More</a>';
    }
    add_filter( 'the_excerpt', 'themprefix_excerpt_read_more_link' );

    Hope this helps.

    #359290

    sbromley
    Participant

    Thank you!!! All working now, as hoped.

    #359419

    Prasant Rai
    Moderator

    You are most welcome 🙂 .

    #638364

    mtomlin
    Participant

    Hi Themeco Staff,

    Glad I found this post, as I like to do my editing in Cornerstone.

    Just a couple of questions, though:
    1. The ‘read more’ text that is displayed in the excerpt is in all caps. How can I change it to sentence case?
    2. How can I remove the READ MORE link from the excerpt of really short blogs, where there would be no more content to view?

    I’ve attached a screenshot with notes so you can get a better idea of what I mean. (I’m using the ICON stack, if that also helps.)

    Many thanks,

    Mel

    #638456

    Rad
    Moderator

    Hi Mel,

    You can try this one replacing the code above.

    //Read More Button For Excerpt
    function themprefix_excerpt_read_more_link($output) {
        global $post;
        
        return str_word_count( $output, 0 ) <= 10 ? $output : $output . ' <a href="' . get_permalink($post->ID) . '" class="more-link" title="Read More">Read More</a>';
    
    }
    add_filter( 'the_excerpt', 'themprefix_excerpt_read_more_link' );

    This str_word_count( $output, 0 ) <= 10 means skip adding read me if the content has only 10 words.

    As for read me styling, add this css at Admin > Appearance > Customizer > Custom > CSS.

    .more-link {
        text-transform: lowercase;
    }

    Cheers!

    #638603

    mtomlin
    Participant

    Hi Themeco Staff,

    Worked like a charm!

    Thank you very much for your help 🙂

    Mel

    #638620

    Rue Nel
    Moderator

    Hello Mel,

    You’re welcome! We are just glad we were able to help you out.
    Thanks for letting us know that it has worked for you.

    Cheers.