[Resolved] Conditional 'Read More' text changes

Home Forums Support [Resolved] Conditional 'Read More' text changes

Home Forums Support Conditional 'Read More' text changes

  • This topic has 2 replies, 2 voices, and was last updated 4 years ago by Greg.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1249687
    Greg

    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

    #1250072
    Tom
    Lead Developer
    Lead Developer

    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;
    } );
    #1250900
    Greg

    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

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