Извлечение заголовка страницы, отрывка и контента по идентификатору: подробное руководство

$page_id = 123; // Replace with the actual page ID
// Get the page title
$page_title = get_the_title($page_id);
// Get the page excerpt
$page_excerpt = get_the_excerpt($page_id);
// Get the page content
$page_content = get_post_field('post_content', $page_id);

Метод 2: запрос к базе данных
Если вы не используете систему управления контентом или вам нужен более индивидуальный подход, вы можете напрямую запросить базу данных для получения нужной информации. Вот пример использования MySQL:

$page_id = 123; // Replace with the actual page ID
// Connect to the database (assuming you already have a connection)
$query = "SELECT post_title, post_excerpt, post_content FROM wp_posts WHERE ID = $page_id";
$result = mysqli_query($connection, $query);
if ($result) {
    $row = mysqli_fetch_assoc($result);
    // Get the page title
    $page_title = $row['post_title'];
    // Get the page excerpt
    $page_excerpt = $row['post_excerpt'];
    // Get the page content
    $page_content = $row['post_content'];
}
// Don't forget to close the database connection
mysqli_close($connection);

Метод 3. Использование REST API
Если ваш контент предоставляется через REST API, вы можете использовать вызовы API для получения необходимой информации. Вот пример использования REST API WordPress:

const pageId = 123; // Replace with the actual page ID
// Fetch the page data
fetch(`https://example.com/wp-json/wp/v2/pages/${pageId}`)
    .then(response => response.json())
    .then(data => {
        // Get the page title
        const pageTitle = data.title.rendered;
        // Get the page excerpt
        const pageExcerpt = data.excerpt.rendered;
        // Get the page content
        const pageContent = data.content.rendered;
    });