WordPress.org

Make WordPress Core

Ticket #36934: test-excerpt.php

File test-excerpt.php, 331 bytes (added by magicroundabout, 4 years ago)

Sample theme template file for reproducing the issue

Line 
1<?php
2/*
3 * Template name: Excerpt test
4 */
5
6if ( have_posts() ) : the_post();
7
8        $latest_posts = get_posts( [ 'posts_per_page' => 1 ] );
9        $latest_post = current( $latest_posts );
10?>
11        <h1><?php echo esc_html( get_the_title( $latest_post ) ); ?></h1>
12        <p><?php echo esc_html( get_the_excerpt( $latest_post ) ); ?></p>
13<?php
14
15endif;
16