# ultimate-store-kit/3.0.9/includes/builder/builder-post-singleton.php

Ultimate Store Kit, version 3.0.9. 54 lines.

- Page: https://pluginprobe.com/plugins/ultimate-store-kit/3.0.9/code/includes/builder/builder-post-singleton.php
- Raw: https://pluginprobe.com/plugins/ultimate-store-kit/3.0.9/raw/includes/builder/builder-post-singleton.php
- Modified: 2026-08-10T12:16:36+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/ultimate-store-kit/3.0.9/code/includes/builder/builder-post-singleton.php#L10-L20`.

```php
<?php

namespace UltimateStoreKit\Includes\Builder;

use  UltimateStoreKit\Base\Singleton;

class Builder_Post_Singleton {
    use Singleton;

    public static function set_sample_post($postId = null) {
        global $post;

        if (!$postId) {
            $postId = $post->ID;
        }

        $meta = get_post_meta($postId);

        $templateMeta = optional($meta)[Meta::TEMPLATE_TYPE];

        if (!isset($templateMeta[0])) {
            return;
        }

        $postMeta = $templateMeta[0];
        $postMeta = explode('|', $postMeta);
        $postType = $postMeta[0];

        $args = [
            'post_type' => $postType,
            'post_status' => ['publish', 'pending', 'draft', 'future'],
            'posts_per_page' => 1,
        ];

        $page_settings_manager = \Elementor\Core\Settings\Manager::get_settings_managers('page');
        $page_settings_model = $page_settings_manager->get_model($postId);
        $sample_product = $page_settings_model->get_settings('usk_builder_sample_post_id');

        if ($sample_product) {
            $args['p'] = $sample_product;
        }

        $wp_query = new \WP_Query($args);

        if ($wp_query->have_posts()) {
            $post = $wp_query->posts[0];
            set_transient('ultimate_store_template_id_' . get_current_user_id(), $postId);
            set_transient('ultimate_store_template_sample_post_' . get_current_user_id(), $wp_query);
            $GLOBALS['post'] = $post;
            setup_postdata($post);
        }
    }
}

```
