Created
August 30, 2016 06:44
-
-
Save neilgee/912ec3267b9519aa5ba22f959232effd to your computer and use it in GitHub Desktop.
Conditional Argument for Multiple CPTs in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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