get_the_excerpt example

function the_excerpt() {

    /** * Filters the displayed post excerpt. * * @since 0.71 * * @see get_the_excerpt() * * @param string $post_excerpt The post excerpt. */
    echo apply_filters( 'the_excerpt', get_the_excerpt() );
}

/** * Retrieves the post excerpt. * * @since 0.71 * @since 4.5.0 Introduced the `$post` parameter. * * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. * @return string Post excerpt. */
if ( ! isset( $block->context['postId'] ) ) {
        return '';
    }

    /* * The purpose of the excerpt length setting is to limit the length of both * automatically generated and user-created excerpts. * Because the excerpt_length filter only applies to auto generated excerpts, * wp_trim_words is used instead. */
    $excerpt_length = $attributes['excerptLength'];
    $excerpt        = get_the_excerpt( $block->context['postId'] );
    if ( isset( $excerpt_length ) ) {
        $excerpt = wp_trim_words( $excerpt$excerpt_length );
    }

    $more_text           = ! empty( $attributes['moreText'] ) ? '<a class="wp-block-post-excerpt__more-link" href="' . esc_url( get_the_permalink( $block->context['postId'] ) ) . '">' . wp_kses_post( $attributes['moreText'] ) . '</a>' : '';
    $filter_excerpt_more = static function( $more ) use ( $more_text ) {
        return empty( $more_text ) ? $more : '';
    };
    /** * Some themes might use `excerpt_more` filter to handle the * `more` link displayed after a trimmed excerpt. Since the * block has a `more text` attribute we have to check and * override if needed the return value from this filter. * So if the block's attribute is not empty override the * `excerpt_more` filter and return nothing. This will * result in showing only one `read more` link at a time. */
if ( isset( $attributes['displayPostDate'] ) && $attributes['displayPostDate'] ) {
            $list_items_markup .= sprintf(
                '<time datetime="%1$s" class="wp-block-latest-posts__post-date">%2$s</time>',
                esc_attr( get_the_date( 'c', $post ) ),
                get_the_date( '', $post )
            );
        }

        if ( isset( $attributes['displayPostContent'] ) && $attributes['displayPostContent']
            && isset( $attributes['displayPostContentRadio'] ) && 'excerpt' === $attributes['displayPostContentRadio'] ) {

            $trimmed_excerpt = get_the_excerpt( $post );

            if ( post_password_required( $post ) ) {
                $trimmed_excerpt = __( 'This content is password protected.' );
            }

            $list_items_markup .= sprintf(
                '<div class="wp-block-latest-posts__post-excerpt">%1$s</div>',
                $trimmed_excerpt
            );
        }

        
return ' &hellip; ' . $link;
}

/** * Displays the post excerpt for the embed template. * * Intended to be used in 'The Loop'. * * @since 4.4.0 */
function the_excerpt_embed() {
    $output = get_the_excerpt();

    /** * Filters the post excerpt for the embed template. * * @since 4.4.0 * * @param string $output The current post excerpt. */
    echo apply_filters( 'the_excerpt_embed', $output );
}

$post_type_object = get_post_type_object( $post->post_type );
            echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
        }

        echo "</strong>\n";

        if ( 'excerpt' === $mode
            && ! is_post_type_hierarchical( $this->screen->post_type )
            && current_user_can( 'read_post', $post->ID )
        ) {
            if ( post_password_required( $post ) ) {
                echo '<span class="protected-post-excerpt">' . esc_html( get_the_excerpt() ) . '</span>';
            } else {
                echo esc_html( get_the_excerpt() );
            }
        }

        get_inline_data( $post );
    }

    /** * Handles the post date column output. * * @since 4.3.0 * * @global string $mode List table view mode. * * @param WP_Post $post The current WP_Post object. */

function the_content_feed( $feed_type = null ) {
    echo get_the_content_feed( $feed_type );
}

/** * Displays the post excerpt for the feed. * * @since 0.71 */
function the_excerpt_rss() {
    $output = get_the_excerpt();
    /** * Filters the post excerpt for a feed. * * @since 1.2.0 * * @param string $output The current post excerpt. */
    echo apply_filters( 'the_excerpt_rss', $output );
}

/** * Displays the permalink to the post for use in feeds. * * @since 2.3.0 */
Home | Imprint | This part of the site doesn't use cookies.