• Hi,

    thanks for the great plugin. Would be great, if you could make use of existing WordPress methods to acquire the excerpt to be displayed in the card. The method is called get_the_excerpt because it also provides filters to change the content of excerpt for the whole WordPress site.

    Please find attached a patch to make use of the function. Furthermore, you can consider to make use of the filter excerpt_length to change the size of the excerpt. Thus, you could benefit from the more readable word-based excerpt shortening, which leaves words in the excerpt intact.

    --- lib/class-childpagescard.org.php    2025-07-09 16:10:43.766264250 +0200
    +++ lib/class-childpagescard.php 2025-07-09 16:33:01.166148567 +0200
    @@ -224,11 +224,11 @@

    $title = $child->post_title . ' - ' . get_option( 'blogname' );

    - $excerpt = null;
    + $excerpt = get_the_excerpt($child->ID);
    if ( function_exists( 'mb_substr' ) ) {
    - $excerpt = mb_substr( strip_shortcodes( wp_strip_all_tags( $child->post_content ) ), 0, $settings['excerpt'] ) . '...';
    - } else {
    - $excerpt = substr( strip_shortcodes( wp_strip_all_tags( $child->post_content ) ), 0, $settings['excerpt'] ) . '...';
    + $excerpt = mb_substr( $excerpt, 0, $settings['excerpt'] ) . '...';
    + } else {
    + $excerpt = substr( $excerpt, 0, $settings['excerpt'] ) . '...';
    }

    $url = get_permalink( $child->ID );

The topic ‘Please use’ is closed to new replies.