Skip to content

Instantly share code, notes, and snippets.

@Archie22is
Created March 21, 2024 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Archie22is/0207cb1e9e7ebccf40f200f2ce0c4361 to your computer and use it in GitHub Desktop.
Save Archie22is/0207cb1e9e7ebccf40f200f2ce0c4361 to your computer and use it in GitHub Desktop.
Content type related post excerpt in WordPress (Not Clean)
<?php
function new_excerpt_more($more) {
global $post;
$current_post_type = get_post_type();
if($current_post_type == 'case_study'):
return '<a href="'. get_permalink($post->ID) . '"><i class="fa fa-arrow-circle-o-right"></i> Read the case study</a>';
endif;
if($current_post_type == 'post'):
return '<a href="'. get_permalink($post->ID) . '"><i class="fa fa-arrow-circle-o-right"></i> Read more</a>';
endif;
}
add_filter('excerpt_more', 'new_excerpt_more');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment