79789335

Date: 2025-10-13 13:58:03
Score: 0.5
Natty:
Report link

Actually my full code will include checking statement to replace the customized text only to product items as below:

function custom_search_read_more_text( $more ) {
    if ( is_search() ) {
        global $post;
        if ( 'product' === get_post_type( $post ) ) {
            return ' <a class="more-link" href="' . get_permalink( $post ) . '">View Product</a>';
        } else {
            return ' <a class="more-link" href="' . get_permalink( $post ) . '">Read More</a>';
        }
    }

    return $more;
}
add_filter( 'excerpt_more', 'custom_search_read_more_text' );

But as I tried just plain returning without the if, none of the above ever worked. So I simplified it here to make they read easier.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: FUFY