WordPress.org

Forums

Quark
[resolved] Change "Continue Reading" (6 posts)

  1. curiouslt
    Member
    Posted 2 years ago #

    I want to change the 'Continue Reading ->' that appears with the except to 'read more..', but I 'm having a bit of trouble figuring it out. I found the function, but I can't get it to change in my child theme.

  2. Anthony Hortin
    Member
    Theme Author

    Posted 2 years ago #

    Hi Nadine,

    If you want to change the "Continue reading" link that is shown when you add a "read more" tag within your content, then you can change this within the content.php template. The the_content() function has a parameter that you pass with the text that you want displayed.

    If you want to change the text for the automatic excerpts that are generated, such as on the search results page. Then add the following functions to your child theme functions.php file.

    function quarkchild_continue_reading_link() {
    	return '&hellip;<p><a class="more-link" href="'. esc_url( get_permalink() ) . '" title="' . esc_html__( 'Continue reading', 'quark' ) . ' &lsquo;' . get_the_title() . '&rsquo;">' . wp_kses( __( 'Read more <span class="meta-nav">&rarr;</span>', 'quark' ), array( 'span' => array(
    			'class' => array() ) ) ) . '</a></p>';
    }
    
    function quarkchild_auto_excerpt_more( $more ) {
    	return quarkchild_continue_reading_link();
    }
    add_filter( 'excerpt_more', 'quarkchild_auto_excerpt_more', 11 );

    What I've done here is duplicated the functions that were in the quark theme that create the "read more" link. I've then simply renamed them (so you don't get any php errors by having duplicate function names) and then used these on the "excerpt_more" filter. I've also specified the priority as 11 so that it gets called after the filter in the parent Quark theme (and thereby overriding it).

    Hope this helps :-)

  3. Anthony Hortin
    Member
    Theme Author

    Posted 2 years ago #

    Hi Nadine,

    If you want to change the "Continue reading" link that is shown when you add a "read more" tag within your content, then you can change this within the content.php template. The the_content() function has a parameter that you pass with the text that you want displayed.

    If you want to change the text for the automatic excerpts that are generated, such as on the search results page. Then add the following functions to your child theme functions.php file.

    function quarkchild_continue_reading_link() {
    	return '&hellip;<p><a class="more-link" href="'. esc_url( get_permalink() ) . '" title="' . esc_html__( 'Continue reading', 'quark' ) . ' &lsquo;' . get_the_title() . '&rsquo;">' . wp_kses( __( 'Read more <span class="meta-nav">&rarr;</span>', 'quark' ), array( 'span' => array(
    			'class' => array() ) ) ) . '</a></p>';
    }
    
    function quarkchild_auto_excerpt_more( $more ) {
    	return quarkchild_continue_reading_link();
    }
    add_filter( 'excerpt_more', 'quarkchild_auto_excerpt_more', 11 );

    What I've done here is duplicated the functions that were in the quark theme that create the "read more" link. I've then simply renamed them (so you don't get any php errors by having duplicate function names) and then used these on the "excerpt_more" filter. I've also specified the priority as 11 so that it gets called after the filter in the parent Quark theme (and thereby overriding it).

    Hope this helps :-)

  4. Anthony Hortin
    Member
    Theme Author

    Posted 2 years ago #

    Excuse the duplicate posts. Not sure what happened there.

  5. curiouslt
    Member
    Posted 2 years ago #

    thanks so much, the function did the trick!

  6. Anthony Hortin
    Member
    Theme Author

    Posted 2 years ago #

    Glad it helped :-)

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags

No tags yet.