Looking at the documentation for the get_the_excerpt
filter, we can see that it receives the WP_Post
object representing either the current post or the post which was passed in to the get_the_excerpt()
function call.
Thus,
function q_excerpt_custom( $excerpt, $post ) {
if ( get_post_type( $post ) == 'post' ) :
$excerpt_custom = '<a class="card-permalink" href="' . get_permalink( $post ) . '" rel="nofollow"> HA HA HA </a>';
return $excerpt_custom;
endif;
return $excerpt;
}
add_filter( 'get_the_excerpt', 'q_excerpt_custom', 10, 2 );