Site logo

Archived topic

Conditional 'Read More' text changes

2 replies · Started by Greg on April 22, 2020

Viewing posts 1–3 of 3

Hi all

Does anyone know of a way to add a function to change the 'Read More' text link based on a conditional such as a post tag? So for example for all posts tagged with 'Photos' the read more button text could be changed to 'View Photos', etc.

I've found a couple of functions online but they seem to be theme specific.

Thanks for any help
Greg

Hi Greg,

Not 100% sure it will work, but you could try this:

add_filter( 'option_generate_blog_settings', function( $settings ) {
    if ( has_tag( 'photos' ) ) {
        $settings['read_more'] = 'View Photos';
    }

    return $settings;
} );

Thanks for this Tom, just realised I've asked in the wrong forum as I'm using WP Show Posts to load my posts into the page in question, so I'll repost over there!

Thanks
Greg

This archived topic is closed to new replies.