
/* ATM SOFTEK GALLERY API CALLBACK */
function atm_gallery_get_events(WP_REST_Request $request) {

    if (!taxonomy_exists('atm_gallery_event')) {
        return new WP_Error(
            'gallery_taxonomy_missing',
            'Gallery Events taxonomy is not registered.',
            ['status' => 500]
        );
    }

    $terms = get_terms([
        'taxonomy'   => 'atm_gallery_event',
        'hide_empty' => false,
    ]);

    if (is_wp_error($terms)) {
        return $terms;
    }

    $events = [];

    foreach ($terms as $term) {

        $images = get_posts([
            'post_type'      => 'attachment',
            'post_status'    => 'inherit',
            'posts_per_page' => -1,
            'tax_query'      => [
                [
                    'taxonomy' => 'atm_gallery_event',
                    'field'    => 'term_id',
                    'terms'    => $term->term_id,
                ]
            ],
        ]);

        $image_data = [];

        foreach ($images as $img) {
            $image_url = wp_get_attachment_image_url($img->ID, 'large');

            if (!$image_url) {
                continue;
            }

            $image_data[] = [
                'id'      => $img->ID,
                'url'     => wp_get_attachment_image_url($img->ID, 'full'),
                'thumb'   => $image_url,
                'alt'     => get_post_meta($img->ID, '_wp_attachment_image_alt', true),
                'caption' => wp_get_attachment_caption($img->ID),
            ];
        }

        $events[] = [
            'id'          => $term->term_id,
            'name'        => $term->name,
            'slug'        => $term->slug,
            'description' => $term->description,
            'image_count' => count($image_data),
            'cover'       => !empty($image_data) ? $image_data[0]['url'] : '',
            'images'      => $image_data,
        ];
    }

    return rest_ensure_response($events);
}
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//atmsoftek.in/wp-content/plugins/wordpress-seo/css/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://atmsoftek.in/post-sitemap.xml</loc>
		<lastmod>2026-10-28T09:52:06+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://atmsoftek.in/page-sitemap.xml</loc>
		<lastmod>2026-11-05T08:58:56+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Yoast SEO -->