Skip to content

Instantly share code, notes, and snippets.

@neilgee neilgee/cpt.php

Created Aug 30, 2016
What would you like to do?
Conditional Argument for Multiple CPTs in WordPress
// Change Read More Text For Excerpts - change based on CPT
add_filter( 'excerpt_more', 'prefix_read_more_link' );
function prefix_read_more_link( $more ) {
if( in_array( get_post_type(), array('treatment', 'package')) ) { //add in CPTs
return '<a href="' . get_permalink() . '" class="more-link" title="See More">See More</a>'; //change read more text
else { //what all the other post types get
return '<a href="' . get_permalink() . '" class="more-link" title="Read More">Read More</a>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.