Skip to content

Instantly share code, notes, and snippets.

@neilgee
Created August 30, 2016 06:44
Show Gist options
  • Save neilgee/912ec3267b9519aa5ba22f959232effd to your computer and use it in GitHub Desktop.
Save neilgee/912ec3267b9519aa5ba22f959232effd to your computer and use it in GitHub Desktop.
Conditional Argument for Multiple CPTs in WordPress
<?php
// 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