• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Using Excerpts Instead of Content Limit Teasers – Magazine Pro

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Using Excerpts Instead of Content Limit Teasers – Magazine Pro

This topic is: not resolved

Tagged: content limi, excerpts, Magazine Pro, more link, read more

  • This topic has 8 replies, 2 voices, and was last updated 10 years, 10 months ago by Ren Ventura.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • January 12, 2015 at 5:48 pm #137258
    eluviis
    Member

    I've decided to use custom excerpts instead of automatic content limit teasers in my new update to Magazine Pro. However, I noticed the fancy "Read More" button doesn't work when you select excerpts for your homepage widgets or archive pages.

    I looked in the WP codex and found this bit of code to add to functions.php:

    function new_excerpt_more( $more ) {
    	return ' <a class="more-link" href="'. get_permalink( get_the_ID() ) . '">' . __('Read More', 'your-text-domain') . '</a>';
    }
    add_filter( 'excerpt_more', 'new_excerpt_more' );

    Note, the original code uses the class "read-more" but I changed that bit to "more-link" as examining the site with Firebug told me that's what magazine-pro uses for the Read More buttons.

    That said, it still doesn't work.

    Any ideas?

    January 12, 2015 at 7:23 pm #137266
    Ren Ventura
    Member

    Take a look at the post I just wrote:

    http://www.engagewp.com/customize-wordpress-read-more-link/


    Web & Software Developer & Blogger | RenVentura.com | Follow Me on Twitter @CLE_Ren

    January 12, 2015 at 8:03 pm #137269
    eluviis
    Member

    Ah! I just read that and I thought it would be as simple as adding the <!--more--> tag to my excerpts to make the snippet I got from the codex to work... But nope. That didn't do it.

    I'm going to have to take more time and try one of your snippets there and see if I can make it work.

    The reality is I DON'T NEED the read more button, because I believe the image and the title are enough to have the reader click. The problem is that the posts that DON'T have custom excerpts are still having excerpts automatically pulled from the text and those posts are rendering the READ MORE button where the ones with custom manual excerpts are not. So I end up with some posts with and some posts without. Which looks weird.

    January 12, 2015 at 8:49 pm #137279
    Ren Ventura
    Member

    The problem is that the posts that DON’T have custom excerpts are still having excerpts automatically pulled from the text and those posts are rendering the READ MORE button where the ones with custom manual excerpts are not.

    That's because the link needs to be appended to a custom excerpt. I just updated the code to include a snippet that removes WordPress-generated excerpts, meaning there won't be an excerpt if you don't set one. You can combine the last two snippets to get what you're looking for:

    /**
     * Removes excerpts that are generated by WordPress rather than set by user
     * and adds the Read More link to the excerpt
     */
    add_filter( 'get_the_excerpt', 'rv_remove_non_custom_excerpts' );
    function rv_remove_non_custom_excerpts( $output ) {
    
    	global $post;
    
    	if ( $post->post_excerpt == '' ) {
    
    		$output = '';
    
    	} else {
    
    		$output .= rv_filter_read_more_link();
    
    	}
    
    	return $output;
    
    }
    

    Web & Software Developer & Blogger | RenVentura.com | Follow Me on Twitter @CLE_Ren

    January 15, 2015 at 3:16 pm #137596
    eluviis
    Member

    Hi @Ren Ventura, thanks for that. However, I might have caused a misunderstanding.
    If I'm going to be able to add the read more link to custom excerpts, I don't want to stop WP from rendering automatic excerpts from posts that don't have a custom except. I just want to add the read more link to custom excerpts so they match all the posts.

    The reason for this is I have many posts. It'll take me a while to go back and add custom excerpts to all of them. While I get that done, I don't want those posts to render blank excerpts in the meantime. But I do want both custom excerpts and automatic excerpts to have the read more link.

    Hope that makes sense. :/

    Big thanks again,
    Danny

    January 15, 2015 at 8:59 pm #137613
    Ren Ventura
    Member

    Not a problem. I think I just misunderstood what you were looking to do (I thought your preference was to remove the excerpt generated by WordPress).

    In any case, the code is still included in the post I linked to above. Try this exact snippet:

    add_filter( 'excerpt_more', 'rv_filter_read_more_link' );
    add_filter( 'get_the_excerpt', 'rv_do_excerpt_read_more_link' );
    function rv_do_excerpt_read_more_link( $output ) {
    
        global $post;
    
        if ( $post->post_excerpt != '' ) {
    
            $output .= rv_filter_read_more_link();
    
        }
    
        return $output;
    
    }
    
    //* Function that returns the actual link
    function rv_filter_read_more_link() {
        return sprintf( '%3$s', get_permalink(), 'readmore', __( ' [Keep on reading!]' ) );
    }
    

    Web & Software Developer & Blogger | RenVentura.com | Follow Me on Twitter @CLE_Ren

    January 15, 2015 at 9:07 pm #137615
    Ren Ventura
    Member

    I tried fixing the HTML formatting of the last reply but it wouldn't let me. Here's a link instead:

    http://pastebin.com/rgSwaQz3


    Web & Software Developer & Blogger | RenVentura.com | Follow Me on Twitter @CLE_Ren

    January 19, 2015 at 1:39 pm #137966
    eluviis
    Member

    @Ren Ventura - What can I tell you? That worked! Thanks.

    I changed the class of "%2$s" you had there for "more-link" and it picked up Magazine Pro's CSS style for that on the homepage, which is nice. I'm not sure what "%2$s" does or even means, but the style works with the change.

    I also changed the link text from [Keep on reading!] to [ Show me more... ]

    You can see it in action here: http://rallyways.com

    Thanks again,
    Danny

    January 19, 2015 at 4:17 pm #137987
    Ren Ventura
    Member

    Awesome! Glad to see you got it working.

    The "%2$s" is a part of the printf() function, which is basically an easier way of formatting a string when it's generated at least partially by functions and variables. Replacing it with your own text is perfectly fine.


    Web & Software Developer & Blogger | RenVentura.com | Follow Me on Twitter @CLE_Ren

  • Author
    Posts
Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble