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;