[Resolved] Is there a way to change the automatic "…" to "[…]" in GP

Home Forums Support [Resolved] Is there a way to change the automatic "…" to "[…]" in GP

Home Forums Support Is there a way to change the automatic "…" to "[…]" in GP

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #314864
    sdanbu

    All post excerpts are changed to show “…” when the excerpt is cut off. It looks funny because the author did not write …

    Is there a way to change the automatic “…” to “[…]”?

    #314872
    Leo
    Staff
    Customer Support

    Hi Scott,

    This function should work:

    add_action( 'after_setup_theme','tu_remove_read_more' );
    function tu_remove_read_more() {
        remove_filter( 'excerpt_more', 'generate_blog_excerpt_more', 99 );
    }
    
    add_filter( 'excerpt_more', 'tu_blog_excerpt_more', 99 );
    function tu_blog_excerpt_more( $more ) {
        if ( ! function_exists( 'generate_blog_get_defaults' ) )
            return;
    
        $generate_settings = wp_parse_args( 
            get_option( 'generate_blog_settings', array() ), 
            generate_blog_get_defaults() 
        );
    	
        // If empty, return
        if ( '' == $generate_settings['read_more'] )
            return;
    		
        return ' [...] <a title="' . esc_attr( get_the_title() ) . '" class="read-more" href="'. esc_url( get_permalink( get_the_ID() ) ) . '">' . $generate_settings['read_more'] . '</a>';
    }

    Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets

    If you don’t have anything entered in Customizer > Blog > Blog Content > Read more label, then try inserting a space.

    Let me know.

    #314893
    sdanbu

    I tried this it didn’t work maybe i did something wrong

    I downloaded and installed code snippets plugin

    Then I added a new snipped and copied the above (see below)

    add_action( ‘after_setup_theme’,’tu_remove_read_more’ );
    function tu_remove_read_more() {
    remove_filter( ‘excerpt_more’, ‘generate_blog_excerpt_more’, 99 );
    }

    add_filter( ‘excerpt_more’, ‘tu_blog_excerpt_more’, 99 );
    function tu_blog_excerpt_more( $more ) {
    if ( ! function_exists( ‘generate_blog_get_defaults’ ) )
    return;

    $generate_settings = wp_parse_args(
    get_option( ‘generate_blog_settings’, array() ),
    generate_blog_get_defaults()
    );

    // If empty, return
    if ( ” == $generate_settings[‘read_more’] )
    return;

    return ‘ […] ‘ . $generate_settings[‘read_more’] . ‘‘;
    }

    It didn’t work – nothing changed. Is it because I should do something with my show posts lists?

    After that, I also went to customizer to see blog>blog content>readmore and added a space but nothing changed either.

    #314894
    Tom
    Lead Developer
    Lead Developer

    You could actually simplify it quite a bit now:

    add_filter( 'generate_excerpt_more_output','tu_change_read_more' );
    function tu_change_read_more() {
        return sprintf( ' [...] <a title="%1$s" class="read-more" href="%2$s">Read more</a>',
            the_title_attribute( 'echo=0' ),
            esc_url( get_permalink( get_the_ID() ) )
        );
    }

    Make sure the code snippet you added is actually activated as well.

    #314938
    sdanbu

    I tried creating a snippet and activated it but it still didn’t work.

    I tried both snippets including the most recent one:
    add_filter( ‘generate_excerpt_more_output’,’tu_change_read_more’ );
    function tu_change_read_more() {
    return sprintf( ‘ […] Read more‘,
    the_title_attribute( ‘echo=0’ ),
    esc_url( get_permalink( get_the_ID() ) )
    );
    }

    Do I need to edit function.php?

    #315032
    Tom
    Lead Developer
    Lead Developer

    What version of GP are you using?

    Can you show me a screenshot of the code snippet page?

    #315144
    sdanbu
    #315174
    Tom
    Lead Developer
    Lead Developer

    Any chance you can show me the full page?

    #315194
    sdanbu

    Do you mean like this?
    http://tinypic.com/r/j5xwea/9

    I don’t really know if it’s any different – maybe you meant something else also…

    #315214
    Tom
    Lead Developer
    Lead Developer

    Strange.. Is there any way you can send me temporary admin login details?: https://generatepress.com/contact/

    #315364
    sdanbu

    sent thanks

    #315677
    Tom
    Lead Developer
    Lead Developer

    Ahh you’re using WP Show Posts.

    Try this instead:

    add_filter( 'wpsp_ellipses','tu_wpsp_ellipses' );
    function tu_wpsp_ellipses() {
        return '[...]';
    }
    #318937
    sdanbu

    wizardry

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.