We're merging with GenerateBlocks! Learn more here.

[Resolved] Add Post Title to read more…

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Add Post Title to read more…

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #12435
    Gwen
    Participant

    I’m working on an accessible site where I can’t have multiple ‘read mores’ on one page. What I need to do is add the title of the post to the read more links, i.e., “Read more First Article”, “Read more Second Article”…

    Is there some PHP I can add to functions.php (or elsewhere) to enable this? Thanks!

    #12472
    Tom
    Keymaster

    Hi there,

    Give this a shot:

    add_filter( 'wpsp_read_more_output', function( $output, $settings ) {
        return sprintf( '<div class="wpsp-read-more"><a title="%1$s" class="%4$s" href="%2$s">%3$s</a></div>',
            the_title_attribute( 'echo=0' ),
            esc_url( get_permalink() ),
            'Read more ' . get_the_title(),
            esc_attr( $settings['read_more_class'] )
        );
    }, 10, 2 );

    Let me know 🙂

    #12477
    Gwen
    Participant

    Yes, it works perfectly — thank you so much for this, Tom! Will definitely make a record for use on future accessible sites.

    Really, really appreciate your willingness to do this.

    #12509
    Tom
    Keymaster

    Glad I could help! 🙂

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