Celebrating 7 Years! Get up to $30 off GeneratePress Premium!

[Support request] Blog "read more labels" for custom post types

Home Forums Support [Support request] Blog "read more labels" for custom post types

Home Forums Support Blog "read more labels" for custom post types

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #527301
    Bradley Glonka

    I’ve been stumped on this for a while.

    The sites I build always have a few different custom post types. Typically, they are things like: testimonials, galleries, etc.

    Would it be possible to display a different “read more” phrase conditionally, per content type?

    While searching the forum, I’ve located this code, which allows me to manually change the “read more” verbiage. But I couldn’t figure out how to make it conditional to a post type. Taking it one step further, it would be cool to have a few conditional statements, IE: if testimonial, if gallery, elseif…

    I appreciate any guidance you may have in this matter. Thank you!

    if ( ! function_exists( 'generate_custom_blog_excerpt_more' ) ) :
    	/**
    	 * Prints the read more HTML
    	 */
    	add_filter( 'excerpt_more', 'generate_custom_blog_excerpt_more', 100 );
    	add_filter( 'the_content_more_link', 'generate_custom_blog_excerpt_more', 100 );
    	function generate_custom_blog_excerpt_more( $more ) {
    		$generate_settings = wp_parse_args( 
    			get_option( 'generate_blog_settings', array() ), 
    			generate_blog_get_defaults() 
    		);
    		return '<div class="read-more-button"><a href="'. get_permalink( get_the_ID() ) . '">test</a></div>';
    	}
    endif;
    GeneratePress 2.0.2
    GP Premium 1.6
    #527892
    Leo
    Staff
    Customer Support
    #530329
    Bradley Glonka

    Leo,

    That worked beautifully. Thank you for the guidance!

    #530535
    Leo
    Staff
    Customer Support

    No problem at all!

    I love it when people figure out with little guidance given ๐Ÿ™‚ Good job!

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