function ess_api_random($request) {
    $instance = $request->get_param('instance') ?: 'default';
    $category = $request->get_param('category');
    $exclude_post_id = $request->get_param('exclude_post_id');

    $args = array(
        'post_type'      => 'post',
        'post_status'    => 'publish',
        'posts_per_page' => 1,
        'orderby'        => 'rand',
        'no_found_rows'  => true,
    );

    if (!empty($category)) {
        $args['category_name'] = $category;
    }

    if (!empty($exclude_post_id)) {
        $args['post__not_in'] = array((int) $exclude_post_id);
    }

    $posts = get_posts($args);

    if (empty($posts)) {
        return array('error' => 'No stories found');
    }

    $post = $posts[0];

    $categories = wp_get_post_categories($post->ID, array('fields' => 'names'));
    $category_list = implode(', ', $categories);

    if (!empty($post->post_excerpt)) {
        $excerpt = wp_trim_words($post->post_excerpt, 55, '...');
    } else {
        $words = explode(' ', strip_tags($post->post_content));
        $first_40_words = implode(' ', array_slice($words, 0, 40));
        $excerpt = $first_40_words . '...';
    }

    return array(
        'id'            => $post->ID,
        'title'         => $post->post_title,
        'excerpt'       => $excerpt,
        'link'          => get_permalink($post->ID),
        'image'         => get_the_post_thumbnail_url($post->ID, 'large'),
        'impression_id' => 0,
        'categories'    => $category_list
    );
}<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//englishshortstories.com/wp-content/plugins/wordpress-seo/css/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://englishshortstories.com/post-sitemap.xml</loc>
		<lastmod>2026-09-17T17:33:38+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://englishshortstories.com/page-sitemap.xml</loc>
		<lastmod>2026-09-18T11:07:42+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://englishshortstories.com/attachment-sitemap.xml</loc>
		<lastmod>2026-09-17T17:24:46+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://englishshortstories.com/elementor-hf-sitemap.xml</loc>
		<lastmod>2026-08-30T09:53:33+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://englishshortstories.com/category-sitemap.xml</loc>
		<lastmod>2026-09-17T17:33:38+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://englishshortstories.com/post_tag-sitemap.xml</loc>
		<lastmod>2026-09-17T17:33:38+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://englishshortstories.com/mood-sitemap.xml</loc>
		<lastmod>2026-09-17T17:33:38+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://englishshortstories.com/author-sitemap.xml</loc>
		<lastmod>2026-06-11T11:03:26+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Yoast SEO -->