0

Hi I made a custom post type using the CPT UI plugin, and have a excerpt button to go to it's full page. But when I click on the button, it just loads the front page (where the button is). Is there something wrong with the excerpt code? I'm currently using Understrap framework. Code below:

if ( ! function_exists ( 'all_excerpts_get_more_link' ) ) {
    function all_excerpts_get_more_link($post_excerpt) {

        return $post_excerpt . ' <p><a class="btn btn-secondary understrap-read-more-link" href="'. get_permalink( get_the_ID() ) . '">' . __('VIEW CASE', 'understrap')  . '</a></p>';
    }
}
add_filter('wp_trim_excerpt', 'all_excerpts_get_more_link');
0

You to set the global $post, otherwise your get_the_ID() function won't work because this code is not in a Wordpress loop.

function all_excerpts_get_more_link($post_excerpt) {
    global $post;

    return $post_excerpt . ' <p><a class="btn btn-secondary understrap-read-more-link" href="'. get_the_permalink( get_the_ID() ) . '">' . __('VIEW CASE', 'understrap')  . '</a></p>';
}

add_filter('wp_trim_excerpt', 'all_excerpts_get_more_link');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.